Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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>
#include <stdio.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
int main(void)
{
int fd = open("/dev/sdd", O_WRONLY);
if (fd < 0) {
@toboqus
toboqus / pushingToTemplate.js
Created December 2, 2015 13:23
Pushing an object onto another object if the element names match
/**
* @name pushToTemplate
* @param template
* @param object
* @returns {object}
* @description will push the object onto the template
*/
var pushToTemplate = function pushToTemplate(template, object){
var result = angular.copy(template);
import sqlite3
import calendar
import time
class Database:
_conn = None
def __init__(self):
self._conn = sqlite3.connect("url.db")
cur = self._conn.cursor()
@toboqus
toboqus / Cache-Spec.js
Created December 18, 2015 08:32
Cache for angularjs
/**
* Created by Alex on 20/10/2014.
*/
describe("Service: Cache", function () {
var $interval,
cacheService,
scope,
lo;
@toboqus
toboqus / Count.java
Last active January 4, 2016 08:18
counting number of files within a given directory (Breadth first)
public int count(File root){
if(root == null || !root.exists()){
System.out.println("ERROR: The source drive/directory does not exist.");
return -1;
}
Queue<File> files = new Queue<>();
files.push(root);
@toboqus
toboqus / Backup.java
Created December 31, 2015 14:49
Simple method of replicating the file structure inc files from one drive/directory to another.
package backup;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
public class Backup {
@toboqus
toboqus / Delete.java
Created January 4, 2016 08:18
Deleting empty directories
import java.io.File;
public class Delete {
public static void main(String[] args) {
if(args.length != 1){
System.out.println("ERROR: A path must be specified.");
System.exit(0);
}else{