Skip to content

Instantly share code, notes, and snippets.

@kristian76
kristian76 / gist:4aa7a907c788a8b0fa69
Created March 1, 2016 14:52
Gun DB and node.js
/*
* Package.json
*/
{
"name": "gunner",
"version": "1.0.0",
"description": "",
"main": "http.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",

Pattern Matching

This is a strawman proposal for adding pattern matching to ECMAScript. Pattern matching is useful for matching a value to some structure in a similar way to destructuring. The primary difference between destructuring and pattern matching are the use cases involved - destructuring is useful for binding pieces out of larger structures whereas pattern matching is useful for mapping a value's structure to data or a set of behaviors. In practice this means that destructuring tends to allow many shapes of data and will do its best to bind something out of it, whereas pattern matching will tend to be more conservative.

Additionally, the power of pattern matching is increased substantially when values are allowed to participate in the pattern matching semantics as a matcher as well as a matchee. This proposal includes the notion of a pattern matching protocol - a symbol method that can be implemented by objects that enables developers to use those values in pattern matching. A common scenario w

@rylan
rylan / EclipseJavaProjects.java
Created February 14, 2012 21:05
Get a list of all java projects open in an Eclipse workspace
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
public class EclipseJavaProjects {
public static List<IJavaProject> getJavaProjects() {
List<IJavaProject> projectList = new LinkedList<IJavaProject>();