This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# spec/quick_sort_spec.rb | |
require 'quick_sort' | |
RSpec.describe QuickSort do | |
tests = [ | |
{input: [2, 1, 1], want: [1, 1, 2]}, | |
{input: [6, 2, 0, 1, -3], want: [-3, 0, 1, 2, 6]}, | |
{input: [], want: []}, | |
{input: [1], want: [1]}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# lib/quick_sort.rb | |
class QuickSort | |
def initialize(arr) | |
@arr = arr | |
end | |
def sort | |
sort_subarray(0, @arr.length - 1) | |
return @arr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# script: watch | |
# author: Mike Smullin <[email protected]> | |
# license: GPLv3 | |
# description: | |
# watches the given path for changes | |
# and executes a given command when changes occur | |
# usage: | |
# watch <path> <cmd...> | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
int getComplem(int n) { | |
int b = 0; | |
for (int temp = n; temp != 0; temp >>= 1) { | |
b++; | |
} | |
return ~((~n)^((1 << b) - 1)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head></head> | |
<body> | |
<svg width="960" height="500"></svg> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.2.2/d3.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.15.0/lodash.min.js"></script> | |
<script src="index.js"></script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename T> | |
class custom_priority_queue : public std::priority_queue<T, std::vector<T>> | |
{ | |
public: | |
bool remove(const T& value) { | |
auto it = std::find(this->c.begin(), this->c.end(), value); | |
if (it != this->c.end()) { | |
this->c.erase(it); | |
std::make_heap(this->c.begin(), this->c.end(), this->comp); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Node { | |
int id; | |
unordered_map<int, *Node> neighbours; | |
}; | |
struct Edge { | |
Node *source; | |
Node *dest; | |
int weight; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int gcd(int a, int b) | |
{ | |
while (true) | |
{ | |
if (a == 0) return b; | |
b %= a; | |
if (b == 0) return a; | |
a %= b; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function countCSSRules() { | |
var results = '', | |
log = ''; | |
if (!document.styleSheets) { | |
return; | |
} | |
for (var i = 0; i < document.styleSheets.length; i++) { | |
countSheet(document.styleSheets[i]); | |
} | |
function countSheet(sheet) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find . -type d -empty -exec touch {}/.gitkeep \; |
NewerOlder