Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<button onclick="onClick()">Click Me</button>
<script>
function onClick() {
console.log(InChI.fromMolfile(taxol));
var CSV = require('csv');
CSV()
.from.string('foo\nbar\nbaz')
.on('record', function(row, index) {
if (index === 2) {
this.error(new Error('stop'));
}
})
.on('error', function(err) {
var CSV = require('csv');
CSV()
.from.string('foo\nbar\nbaz')
.on('record', function(row, index) {
if (index === 0) {
this.error(new Error('stop'));
}
})
.on('error', function(err) {
@rapodaca
rapodaca / gist:1943633
Created February 29, 2012 19:13
Failing template render from STRawGroupDir and StringTemplate 4.0.5
package com.kemga.framework;
import static org.junit.Assert.assertEquals;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
@rapodaca
rapodaca / terasology-testing.markdown
Created February 25, 2012 21:16
Terasology Testing FAQ

Q: Why Test?

A: Most developers spend the majority of their time not writing code but debugging and maintaining it. Unit tests are one of the best ways to minimize unnecessary time spent on both. Testing also helps document your code. Finally, we use a passing unit test suite as one of the criteria for accepting pull requests.

Q: What software is used to test?

A: Terasology uses JUnit 4 for its automated test suite. It also uses Mockito for mocking/stubbing in special situations for which a dependency is too expensive or unreliable to bring into a test suite - for example, network activity or OpenGL.

An IDE is highly encouraged for running tests, as most support JUnit. On Eclipse, for example, you can quickly run a single test by right-clicking on the test method declaration and selecting "Run As -> JUnit Test". You can give this command a shortcut key of your choice to make it even faster.

@rapodaca
rapodaca / build.gradle
Created February 24, 2012 07:02
Partial Terasology Gradle build file
// See:
// http://gradle.1045684.n5.nabble.com/Groovy-Java-mixed-codebase-td1435484.html
// http://stackoverflow.com/questions/2572811/gradle-make-a-3rd-party-jar-available-to-local-gradle-repository
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'groovy'
sourceCompatibility = 1.6
version = '0.5.0'
@rapodaca
rapodaca / gist:1264773
Created October 5, 2011 15:45
Importing JSON in PhoneGap
#import <PhoneGap/JSON.h>
@implementation Test
-(void)foo:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options {
NSDictionary *map = [NSDictionary dictionary];
NSString *json = [map JSONRepresentation];
NSLog(@"%@", json);
}
@end
@rapodaca
rapodaca / gist:1260721
Created October 4, 2011 01:40
HTML for container + floated children
<div class="wrapper" style="overflow: auto;">
<div class="child" style="float: left;" ></div>
<div class="child" style="float: left;" ></div>
</div>
@rapodaca
rapodaca / gist:1245529
Created September 27, 2011 16:22
Test
chemtab.browser.FileView.prototype.wiggle = function() {
goog.dom.classes.add(this.getElement(), 'wiggle');
};
@rapodaca
rapodaca / gist:1241613
Created September 26, 2011 04:31
Distance from a point to a line or segment.
/**
* See: http://jsfromhell.com/math/dot-line-length
*
* Distance from a point to a line or segment.
*
* @param {number} x point's x coord
* @param {number} y point's y coord
* @param {number} x0 x coord of the line's A point
* @param {number} y0 y coord of the line's A point
* @param {number} x1 x coord of the line's B point