Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Jabari Dash N02870941

View GitHub Profile
@N02870941
N02870941 / Threads.java
Last active Feb 15, 2019
A simple Java class with a one-liner that utilizes Java 8 lambdas to concisely demonstrate how to use threads and accomplish concurrency in Java.
View Threads.java
import java.util.stream.IntStream;
class Threads {
public static void main(String... args) {
IntStream
.range(0, 10)
.mapToObj(i -> new Thread(() -> System.out.println(Thread.currentThread().getName())))
.forEach(thread -> thread.start());
View Quicksort.java
import java.util.concurrent.ThreadLocalRandom;
import java.util.Arrays;
/**
* Quicksort implementation that counts that
* number of comparisons required to perform the sort.
*
* @author Jabari Dash
*/
public class QuickSort {
@N02870941
N02870941 / sorting.py
Created Sep 12, 2018
A few sorting algorithms in Python
View sorting.py
import math
import random
#-------------------------------------------------------------------------------
'''
Default comparator that sorts
numeric values in their natural order.
'''
def comparator(one, two):
View quicksort.js
/**
* Sorts an array of values. An optional
* 2 parameter comparator function is available
* to specify ordering. If no comparator is
* supplied, then the values will be sorted
* based on their primitive values via the
* Object.prototype.valueOf() function.
*/
function sort(array, comparator = (a, b) => a.valueOf() - b.valueOf()) {
@N02870941
N02870941 / Contains.java
Created Aug 3, 2018
Various ways to check is a 2-dimensional ArrayList contains a specified value
View Contains.java
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Objects;
import java.util.stream.Collectors;
public class Contains {
@N02870941
N02870941 / bst.go
Created Jun 29, 2018
Binary Search Tree in GoLang
View bst.go
package main
import "fmt"
import "strconv"
//------------------------------------------------------------------------------
type Node struct {
data int
@N02870941
N02870941 / Timsort
Created May 1, 2018 — forked from nandajavarma/Timsort
Timsort implementation using Python
View Timsort
#!/usr/lib/python
# -*- coding: utf-8 -*-
#
# This is a re-implementation of Python's timsort in Python
# itself. This is purely for learning purposes. :)
# References: [
# https://en.wikipedia.org/wiki/Timsort,
# http://wiki.c2.com/?TimSort
# ]
#
@N02870941
N02870941 / ToBinary.java
Last active Sep 12, 2018
Convert decimal integer to binary string
View ToBinary.java
public class ToBinary {
/**
* Converts a positive integer to binary.
*
* @param decimal Decimal number.
* @return Binary string.
*/
public static String binary(int decimal) {
@N02870941
N02870941 / back_forward.js
Created Dec 13, 2017 — forked from sstephenson/back_forward.js
How to detect whether a hash change came from the Back or Forward button
View back_forward.js
var detectBackOrForward = function(onBack, onForward) {
hashHistory = [window.location.hash];
historyLength = window.history.length;
return function() {
var hash = window.location.hash, length = window.history.length;
if (hashHistory.length && historyLength == length) {
if (hashHistory[hashHistory.length - 2] == hash) {
hashHistory = hashHistory.slice(0, -1);
onBack();
You can’t perform that action at this time.