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 <cassert> | |
#include <functional> | |
#include <iostream> | |
#include <list> | |
#include <string> | |
#include <vector> | |
template <typename T, typename BinaryPredicate> | |
void bounded_remove_if(T &values, | |
BinaryPredicate predicate, |
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/python3.3 | |
import sys | |
import subprocess | |
# The git hook will invoke this script with some data in STDIN | |
# So, let's re-assign stdin to /dev/tty so we can grab user input | |
# and decide whether or not to tweet this commit | |
sys.stdin = open('/dev/tty') | |
shouldTweet = input('Tweet this commit? y/n: ') | |
if shouldTweet != "y" and shouldTweet != "Y": |
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
/* Given an input string of size n, return the number of occurrences | |
* of the most common substring between lengths k,l. | |
*/ | |
int findOccurrencesOfMostCommonSubstring(int n, int k, int l, const string &input) | |
{ | |
std::map<std::string, int> substringMap; | |
int maxOccurrences = 1; | |
// 1. Build every legal substring with lengths between k and l | |
// 2. Place into map |
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
#!/bin/bash | |
# | |
# Sample usage: | |
# Find "QObject" in every .hpp / .cpp file located somewhere within /home/zach/coderoot | |
# dofind.sh "QObject" hs /home/zach/coderoot | |
# | |
# Same as above, but begin the search in the current directory, and only check .cpp files | |
# dofind.sh "QObject" s | |
# | |
# Same as above, but specify the file extension manually |
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
#!/bin/bash | |
ps aux | grep -m 1 $1 | awk '{print $2}' |
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
public static String reverse(String str) | |
{ | |
int startIndex = 0; | |
int stopIndex = str.length() - 1; | |
char[] chArray = str.toCharArray(); | |
while (startIndex < stopIndex) | |
{ | |
char temp = chArray[stopIndex]; | |
chArray[stopIndex] = chArray[startIndex]; | |
chArray[startIndex] = temp; |
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
def fibonacci(nthTerm): | |
if nthTerm < 2: | |
return nthTerm | |
else: | |
return fibonacci(nthTerm - 1) + fibonacci(nthTerm - 2) |
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
def findLargestIterative(theList): | |
if len(theList) > 0: | |
largest = theList[0] | |
for item in theList: | |
if item > largest: | |
largest = item | |
return largest | |
else: | |
return None |
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 <iostream> | |
#include <fstream> | |
#include <stdlib.h> | |
#include <string> | |
using namespace std; | |
int main(const int argc, const char* argv[]) | |
{ | |
if (argc != 2) | |
{ |
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
def printOdds(startVal, endVal): | |
for odd in range(startVal, endVal + 1, 2): | |
print(str(odd)) |
NewerOlder