Skip to content

Instantly share code, notes, and snippets.

View gijs's full-sized avatar

Gijs Nijholt gijs

View GitHub Profile
var mongoose = require('mongoose');
mongoose.connect('localhost', 'testing_multiTenant');
/**
* User schema.
*/
var UserSchema = new mongoose.Schema({
name: String
, prefix: { type: String, required: true }
@gijs
gijs / example-user.js
Created May 4, 2012 10:53 — forked from nijikokun/example-user.js
Beautiful Validation... Why have I never thought of this before?!
var user = {
validateCredentials: function (username, password) {
return (
(!(username += '') || username === '') ? { error: "No Username Given.", field: 'name' }
: (!(username += '') || password === '') ? { error: "No Password Given.", field: 'pass' }
: (username.length < 3) ? { error: "Username is less than 3 Characters.", field: 'name' }
: (password.length < 4) ? { error: "Password is less than 4 Characters.", field: 'pass' }
: (!/^([a-z0-9-_]+)$/i.test(username)) ? { error: "Username contains invalid characters.", field: 'name' }
: false
);
@gijs
gijs / gauge.js
Created February 25, 2012 20:26 — forked from tomerd/gauge.js
google style gauges using javascript d3.js
function Gauge(placeholderName, configuration)
{
this.placeholderName = placeholderName;
var self = this; // some internal d3 functions do not "like" the "this" keyword, hence setting a local variable
this.configure = function(configuration)
{
this.config = configuration;
@gijs
gijs / Rakefile
Created December 20, 2011 22:35 — forked from erochest/Rakefile
Vagrant/Rake config files for setting up a GeoServer instance.
require 'etc'
require 'fileutils'
require 'vagrant'
task :default => :usage
task :usage do
puts "You forgot to tell the computer what to do; try one of these commands:"
@gijs
gijs / 04_jshint.rake
Created October 25, 2011 08:01 — forked from jamesarosen/04_jshint.rake
Javascript Loves CI: Jenkins + Jasmine + PhantomJS + JSHint
namespace :jshint do
task :require do
sh "which jshint" do |ok, res|
fail 'Cannot find jshint on $PATH' unless ok
end
end
task :check => 'jshint:require' do
project_root = File.expand_path('../../', File.dirname(__FILE__))
config_file = File.join(project_root, 'config', 'jshint.json')
@gijs
gijs / watchout.cfg
Created October 12, 2011 08:56
Projectwatch-buildout for SCSS and CoffeeScript compilation
# Usage::
#
# bin/buildout -c watchout.cfg
# source bin/activate
# projectwatch src/my.project
# deactivate
#
# See also: https://github.com/epeli/Projectwatch
[buildout]
// jslint configuration
/*jslint browser: true */
/*global $, window */
var console = console || {
log:function() {},
warn: function() {},
dir: function() {},
error: function() {}
};
var console = console || {
log:function() {},
warn: function() {},
dir: function() {},
error: function() {}
};
root@jupiter:/tmp# rm -rf *
rm: invalid option -- '0'
Try `rm ./-0m-D7' to remove the file `-0m-D7'.
Try `rm --help' for more information.
@gijs
gijs / index.html
Created June 30, 2011 10:16
Javascript Combinations problem
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Checkbox Combo Spike</title>
<style>
body{
font-family: 'Helvetica';
font-size: .8em;
}