Skip to content

Instantly share code, notes, and snippets.

View dervalp's full-sized avatar

Pierre dervalp

View GitHub Profile
@dervalp
dervalp / gist:4143353
Created November 25, 2012 12:46
Find Word
module.exports = function(){
var mongoose = require('mongoose')
, _ = require("underscore")
, twitter = require('ntwitter')
, User = require('./model')(mongoose).user
, Action = require('./model')(mongoose).action;
mongoose.connect('mongodb://mongohq.com:10001/scocialcrawler');
var twit = new twitter({
@dervalp
dervalp / gist:3937401
Created October 23, 2012 07:14
Pipelines
We couldn’t find that file to show.
@dervalp
dervalp / gist:3910258
Created October 18, 2012 07:13
Blanket - more object oriented ?
/**
* Module Depedencies
*/
var path = require('path');
/**
* Export
*/
exports = module.exports = Blanket;
/**
@dervalp
dervalp / gist:3754258
Created September 20, 2012 06:27
Writing javascript in a declarative way
!function($) {
"use strict"; // jshint ;_;
var customEl = '[data-toggle="sc-toggle"]'
, Toggle = function(el) {
var $el = $(element).on('click.customevent.data-api', this.toggle)
$('html').on('click.customevent.data-api', function() {
$el.parent().removeClass('open')
})
@dervalp
dervalp / gist:3665890
Created September 7, 2012 12:38
Feedback
define([
"app"
// Modules
// Plugins
],
/*
Questions ?
- Do we need to add the div#flash in the page or do we add it if is not present on the first notification? (like lazy initialization)
- Do we allowed our user to close the error message ? Some UX rules say that you cannot close an error or a warning, but you can close information,
@dervalp
dervalp / gist:2843309
Created May 31, 2012 13:07
Understanding Curry
var add = function(a, b, c) {
return a + b + c;
};
Function.prototype.method = function(name, func) {
this.prototype[name] = func;
return this;
};
Function.method('curry', function() {
//keep the value of curry inside a closure
@dervalp
dervalp / gist:1853521
Created February 17, 2012 13:45
Mapper C#
[AttributeUsage(AttributeTargets.Property)]
public sealed class NotMappingAttribute : Attribute
{
public bool Value { get; private set; }
public NotMappingAttribute()
{
Value = true;
}
}
@dervalp
dervalp / Generic repository for NHIBERNATE
Created February 17, 2012 13:36
Generic Repository
public class Repository<T> : IRepository<T> where T : class, IEntity
{
private readonly ISession _session;
private readonly IDalValidator<T> _dalValidator;
public Repository(ISession session, IDalValidator<T> dalValidator)
{
_session = session;
_dalValidator = dalValidator;
}
@dervalp
dervalp / Birthdate.js
Created January 9, 2012 19:55
Control for Birthdate with Date.js
//reference Date.js
if (!Utilities) var Utilities = {};
$.extend(Utilities,
{
Birthdate : function(lg) {
var Month = {
en : ["January","February","March","April","May","June","July","August","September","October","November","December"],
fr : ["janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre"]
}