Skip to content

Instantly share code, notes, and snippets.

View vdurmont's full-sized avatar

Vincent Durmont vdurmont

View GitHub Profile
@vdurmont
vdurmont / Main.java
Created January 7, 2014 18:45
First use of APIPixie
// Create an APIPixie instance
APIPixie pixie = new APIPixie("http://api.mydistantservice.com");
// Retrieve an APIService for your object
APIService<Message> msgService = pixie.getService(Message.class);
// Start communicating with the distant API
Message msg = msgService.get(42L);
// Now do stuff with the object!
@vdurmont
vdurmont / gist.rb
Created January 6, 2014 20:28 — forked from gsong/gist.rb
require 'cgi'
require 'open-uri'
# Require the ActiveSupport::Cache module
require 'active_support/cache'
module Fiftyfive
module Liquid
class GistTag < ::Liquid::Tag
def initialize(tag_name, gist_ref, tokens)
@vdurmont
vdurmont / bug.json
Created November 26, 2013 19:26
model example
{
"id": 42,
"title": "Wrong format for the creation date",
"creation": "2013-11-27T04:33:35Z",
"status": "OPEN",
"assignee": "Vincent"
}
@vdurmont
vdurmont / config.json
Created November 26, 2013 19:25
database config for a mongodb-based app
{
"host": "localhost",
"dbname": "example"
}
@vdurmont
vdurmont / app.js
Created November 26, 2013 19:23
main file for a basic express.js API
var express = require('express');
var routes = require('./routes.js');
var app = express();
app.use(express.bodyParser());
app.get('/', routes.getAll);
app.post('/', routes.create);
app.get('/:id', routes.get);
app.put('/:id', routes.update);
@vdurmont
vdurmont / routes.js
Created November 26, 2013 19:24
database and request handler for a basic express.js API
var config = require('./config.json');
var monk = require('monk');
var db = monk(config.host+'/'+config.dbname);
var collection = db.get('bugs');
// Returns all the bugs
exports.getAll = function(req, res) {
collection.find({}, function(err, bugs){
if (err) res.json(500, err);
else res.json(bugs);
@vdurmont
vdurmont / package.json
Created November 26, 2013 19:22
Basic package.json to import express.js and monk in a node project
{
"name": "MyApp",
"version": "0.0.1",
"private": true,
"dependencies": {
"express": "3.4.4",
"monk": "0.7.1"
}
}
var express = require('express');
var app = express();
// Jade
app.set('views', __dirname+'/views');
app.set('view engine', 'jade');
app.get('/', function(req, res){
var name = req.query.name;
if (name == null)
doctype html5
html
head
title #{title}
link(rel="stylesheet", href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css")
body
div.container(style="max-width: 800px;")
h1 My sample app
block content
extends layout
block content
p Hello again World.
p The current date is: #{date}
p.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse