Skip to content

Instantly share code, notes, and snippets.

// The function is supposed to return false when
// x+y overflows unsigned short.
// Does the function do it correctly?
bool IsValidAddition( unsigned short x,
unsigned short y) {
if (x+y < x)
return false;
return true;
}
@scottopell
scottopell / HDFS-8748.patch
Created July 27, 2015 21:46
HDFS 8748 rejected patch
diff --git hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSPermissionChecker.java hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSPermissionChecker.java
index e6570f5..0144ac4 100644
--- hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSPermissionChecker.java
+++ hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSPermissionChecker.java
@@ -20,6 +20,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.Set;
@scottopell
scottopell / restart_modem.sh
Last active August 29, 2015 14:27
Restart a SB6183 Modem via cURL
curl -X POST -d 'Rebooting=1&RestoreFactoryDefault=0' 'http://192.168.100.1/goform/RgConfiguration.pl'
@scottopell
scottopell / discussions_to_explain.md
Last active October 14, 2015 14:35
Explanations of technical systems posed in the form of a discussion in which the design is iterated on.
@scottopell
scottopell / readme.md
Last active October 28, 2015 01:36
CS352 Project 4 Testing scripts

Test Scripts

Adapted from Austin Schwartz's scripts that he posted on project 2. https://gist.github.com/nawns/3befd88d5bdd39d43e96

These assume you'll be running from the root of the project (ie, alongside src and bin.) Have the tests inside p4tests/output. See the diagram at the bottom for the intended directory structure.

Usage:

./test.sh t1.mj

Or a prettier version with side by side diff (requires sdiff)

@scottopell
scottopell / inline.js
Created March 2, 2016 01:43
Who's Hiring Filter
var keywords = ["NYC", "New York"];
var els = document.getElementsByClassName("athing");
[].forEach.call(els, function(ele){
var regex = new RegExp("\\b" + keywords.join("|") + "\\b");
var elementText = ele.innerHTML; // probably a few false positives, oh well.
if (regex.test(ele.innerHTML)){
ele.style.display = "block";
} else {
ele.style.display = "none";
}
#include <stdio.h>
int main(){
int i = 0;
int a = 3;
int b = 5;
{
int c = 7;
printf(" c: %d\n", c);
printf("&c: %u\n", &c);
}
import java.io.*;
import java.util.*;
public class Solution {
static boolean isAnagram(String A, String B) {
//Complete the function
if (A.length() != B.length())
return false;

Keybase proof

I hereby claim:

  • I am scottopell on github.
  • I am scott_o (https://keybase.io/scott_o) on keybase.
  • I have a public key whose fingerprint is 91BE AEDD 380A FB1E 0616 0057 16BF E230 853D 68F5

To claim this, I am signing this object:

@scottopell
scottopell / create_hound_config.sh
Last active August 5, 2016 16:25
Creates a hound (etsy/hound) configuration file that will index a given users public github repos.
#!/bin/sh
user=scottopell
json=$(curl -s https://api.github.com/users/$user/repos\?type\=owner\&per_page\=300 | jq 'reduce .[] as $pair ( {}; . + { ($pair.name): { url: $pair.html_url } } )')
echo "\
{
\"max-concurrent-indexers\": 2,
\"dbpath\": \"data\",
\"repos\": $json
}"