Skip to content

Instantly share code, notes, and snippets.

View Raynos's full-sized avatar

Jake Verbaten Raynos

View GitHub Profile
define([/* dependencies */], function(dep){
return {
"test my module": function (test) {
// run test
}
};
});
head
meta(charset="utf-8")
meta(http-equiv="X-UA-Compatible", content="IE=edge,chrome=1")
title= title
link(rel='stylesheet', href='/public/js/libs/nodeunit/nodeunit.css')
script(src="/public/js/libs/nodeunit/nodeunit.js")
script(data-main="/public/js/app-test", src="/public/js/libs/require/require.js")
<!-- nodeunit HTML -->
@Raynos
Raynos / verbose.js
Created November 21, 2011 21:35
ES5 is verbose
var Animal = {
legs: 4,
walk: function () { ... }
};
var Cat = Object.create(Animal, {
nyan: {
value: function () { ... },
configurable: true
},
void * thread_start(void *arg) {
while (1) {
/* for each column. Only run columns the thread_num
is assigned to */
for (column_count = thread_num; column_count < dim - 1; column_count+=threads) {
/* do thread work for data chunk */
}
/* barrier */
barrier_result = pthread_barrier_wait(barrier);
@Raynos
Raynos / OO-ified.js
Created November 25, 2011 15:45
pd example
// persons modules
// uses pd - http://raynos.org/blog/17/Improving-ES5-OO-with-pd
var Person = {
fullName: function _fullName() {
return this.firstName + " " + this.lastName;
},
age: function _age() {
return (new Date).getYear() - this.birthDate.getYear();
},
saySomething: function _saySomething() {
@Raynos
Raynos / controller.js
Created November 26, 2011 15:21
Splitting up routers
var Post = require("../domain/post.js"),
PostModel = require("../data/post.js"),
View = require("../view/post.js");
var authorized = [
function _requireLogin(req, res, next) {
if (req.user) {
next();
} else {
res.redirect('/login/');
double** relax(double** matrix, int dim, int threads, double precision) {
double** target;
double** source;
int bytes = dim * dim * sizeof(double);
/* copy matrix into source */
source = (double**) malloc(bytes);
memcpy(source, matrix, bytes);
/* copy matrix into target */;
void * thread_start(void *arg) {
/* init vars */
/* unpack arg */
while (data->finished == 0) {
int barrier_result;
double** temp;
/* for each column. Only run columns the thread_num
void * thread_start(void *arg) {
RELAX_DATA* data;
THREAD_ARG* thread_arg;
int column_count;
int dim;
int thread_num;
int threads;
int precision;
clock_t before;
function foo($) {
// code
}
foo(jQuery);