Skip to content

Instantly share code, notes, and snippets.

View jbranchaud's full-sized avatar

Josh Branchaud jbranchaud

View GitHub Profile
@jbranchaud
jbranchaud / JavaScriptResources.md
Last active August 29, 2015 14:08
JavaScript Resources
@jbranchaud
jbranchaud / TestableJavaScript.md
Last active July 15, 2021 12:36
Resources on writing testable JavaScript

Testable JavaScript Resources

Testing JavaScript isn't just a thing you can read about in children's fairy tales.

This is just a scratch pad of everything I find. As the really good resources start to float to the top, I'll transition them to a more permanent GitHub repo.

General

@jbranchaud
jbranchaud / SomeLinks.md
Last active December 24, 2015 10:09
A bunch of links that I may or may not use at Meulén
public class ItemPrinter {
public static void printItem(Integer i) {
System.out.println(i.toString());
}
public static void printItem(String s) {
System.out.println(s);
}
}
import java.util.List;
public class ListPrinter {
public static void printList(List<Integer> list) {
for(Integer i : list) {
System.out.println(i.toString());
}
}
@jbranchaud
jbranchaud / GenericsErasure.java
Last active December 17, 2015 08:19
An example of Java code that won't compile because of generics erasure.
import java.util.List;
public class GenericsErasure {
public static void main(String[] args) {
//...
}
public static void printList(List list) {
//...
@jbranchaud
jbranchaud / cmdlineSoot.sh
Last active December 17, 2015 06:59
Fun with Soot on the command-line!
# Some commands from using Soot on the command-line
# First, put the Soot jars on your Java CLASSPATH (preferrably through .bashrc or .zshrc)
export SOOTJAR=path/to/sootclasses-2.5.0.jar
export JASMINJAR=path/to/jasminclasses-2.5.0.jar
export POLYGLOTJAR=path/to/polyglotclasses-1.3.5.jar
export CLASSPATH=$SOOTJAR:$JASMINJAR:$POLYGLOTJAR:$CLASSPATH
# Using Soot to compile a single Java file:
# +-project/
@jbranchaud
jbranchaud / dafny-find-common
Last active December 14, 2015 20:38
A common array element method verified by Microsoft's Dafny from http://rjoshi.org/cs116/homework/hw1-common.dfy
/*
* We are given 3 arrays a,b,c of integers sorted in ascending order, and we are told
* that there is a value that occurs in all three arrays. Write a Dafny program to
* compute the index in each array where the common value occurs.
*
* This is the best implementation I can come up with for this problem, however it
* is still not verifiable by Dafny. It is a combination of the loop invariants or
* ensures that seem to fail based on various permutations of saying that p,q,r are
* < or <= a.Length,b.Length,c.Length, respectively. The long requires statement and
* the identical assume statement have been added to keep the previously mentioned
@jbranchaud
jbranchaud / dafny-find
Created March 12, 2013 16:19
An array find method verification from http://rjoshi.org/cs116/homework/hw1-find.dfy
method find(A:array<int>, key: int) returns (k:int)
requires A != null && A.Length > 0 ;
requires A[0] < A[A.Length-1] ;
ensures 0 <= k < A.Length-1 ;
ensures A[k] < A[k+1] ;
{
var i:int := 0;
while(i < A.length) {
if(A[i] == key) {
return i;
@jbranchaud
jbranchaud / dafny-fibonacci
Created March 12, 2013 15:53
Verifying Fibonacci with Microsoft's Dafny
function method Fibonacci(n: int): int
requires n >= 0;
decreases n;
{
if n < 2 then n else Fibonacci(n-2) + Fibonacci(n-1)
}
method Testing() {
assert 0 == Fibonacci(0);
assert 1 == Fibonacci(1);