Skip to content

Instantly share code, notes, and snippets.

@toboqus
toboqus / BinarySearchTree.cpp
Last active October 20, 2023 16:38
BST in C++ with templates
/*
* main.cpp
*
* Created on: 8 Nov 2015
* Author: Alex
*/
#include <iostream>
template <class T>
@toboqus
toboqus / BinarySearchTree.c
Created November 5, 2015 20:14
Binary Search Tree in C
/*
* Tree.c
*
* Created on: 5 Nov 2015
* Author: Alex
*/
#include <stdio.h>
#include <stdlib.h>
@toboqus
toboqus / LinkedList.c
Created November 4, 2015 20:49
Linked list in C
/*
* LinkedList.c
*
* Created on: 4 Nov 2015
* Author: Alex
*/
#include <stdlib.h>
#include <stdio.h>
@toboqus
toboqus / linkedList.cpp
Created November 3, 2015 11:42
Linked List in C++
/*
* linkedList.cpp
*
* Created on: 3 Nov 2015
* Author: Alex
*/
#include <iostream>
#include "linkedList.hpp"
using namespace std;
@toboqus
toboqus / btree.cpp
Created November 3, 2015 08:53
Binary tree implementation in c++
#include <iostream>
using namespace std;
struct node{
int value;
node *left;
node *right;
};
@toboqus
toboqus / xorEncryption.c
Created October 31, 2015 17:41
Simple demonstration on using xor to encrypt data with a key, and a demonstration of an attack with both the plaintext and cyphertext
/*
* xorEncryption.c
*
* Created on: 30 Oct 2015
* Author: Alex
*/
#include <stdio.h>
#include <string.h>
int main(void)
@toboqus
toboqus / RussianPeasant.java
Created September 14, 2015 18:32
Russian peasant algorithm
public class RussianPeasant {
public Static int product(int a, int b){
int x = a;
int y = b;
int z = 0;
while(x > 0){
if(x%2 == 1) z += y;
x = x >> 1;
@toboqus
toboqus / OrderedInsert.js
Last active December 14, 2015 08:43
Ordered insert using binary searching for angularJS
/**
* @name orderedInsert
* @param {Array} collection
* @param {String} key
* @param {Object | array} items - array of objects to insert
* @returns {promise}
* @description will insert an object into a sorted collection using a modified
* form of binary searching. it will also insert an array of objects if that is provided
* instead.
* @example
@toboqus
toboqus / loadDependencies.js
Last active August 29, 2015 14:07
Synchronously execute functions/load dependencies
$scope.loadDependencies = function(arr){
var deferred = $q.defer();
var arrLen = arr.length,i = -1;
(function loadNext(){
i++;
(i < arrLen) ? arr[i](loadNext) : deferred.resolve();
})();
return deferred.promise;
};
@toboqus
toboqus / speedTestJS
Created September 23, 2014 14:44
Performance testing JS
(function(global){
var testFunc = function testFunc(func){
var start = new Date();
func();
return new Date() - start;
},
speedTest = function speedTest(name, func){
var numOfTimes = 1000,