Skip to content

Instantly share code, notes, and snippets.

View dervalp's full-sized avatar

Pierre dervalp

View GitHub Profile
@dervalp
dervalp / example.js
Created August 6, 2015 10:10
PlayMakerSample
var TodoPlayMaker = new PlayMaker({
name:'TodoPlayMaker',
events: [ 'REMOVE_TODO', 'ADD_TODO' ]
});
var UserPlayMaker = new PlayMaker({
name: 'UserPlayMaker',
events: [ 'LOGOUT' ]
});
@dervalp
dervalp / controller
Last active August 29, 2015 14:23
Dirty image crop
var knox = require("knox")
, conf = require("../conf")
, http = require('http')
, url = require('url')
, gm = require('gm')
, conf = require("../conf")
, request = require("request")
, imageMagick = gm.subClass({ imageMagick: true })
, imageHelper = require("./imageHelper")
, fs = require("fs");
@dervalp
dervalp / ko-hammer.js
Created December 18, 2014 14:52
Knockout + Hammer JS Binding
( function( window, ko ) {
var touchEvents = [ 'tap', 'doubletap', 'hold', 'rotate',
'drag', 'dragdown', 'dragup', 'dragleft', 'dragright',
'transform', 'transformstart',
'transformend', 'swipe', 'swipeleft', 'swiperight',
'swipeup', 'swipedown', 'pinch', 'pinchin', 'pinchout'
];
var makeMobileBindings = function( touchEventName ) {
@dervalp
dervalp / gist:db4d2fbfce3a80ac8b94
Created December 2, 2014 14:28
unit test Component (even in node.js env)
var handlebars = require("handlebars");
global.__speak_config = {
template: handlebars
};
var Speak = require( "../../src/index" ),
should = require( "should" );
@dervalp
dervalp / C#
Last active August 29, 2015 14:07
Razor vs C#
namespace Sitecore.Web.UI.Controls.Common.Texts
{
using System.Web.UI;
using Sitecore.Diagnostics;
using Sitecore.Mvc.Presentation;
/// <summary>
/// The type of text.
/// </summary>
public enum TextType
@dervalp
dervalp / eventJS
Created September 25, 2014 13:06
SPEAK Events
!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.SPEAKevent=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
/* jshint forin:false, loopfunc: true */
/**
* This is a module extracted from the backboneJS source code
* but works without Underscore and backbone
*/
var idCounter = 0;
var _uniqueId = function () {
@dervalp
dervalp / gist:8e4ee4d7964df5a0c719
Last active August 29, 2015 14:02
ActivityFeed
var divs = d3.select("#playground").append("svg")
.attr("width", 200)
.attr("height", 200)
.selectAll("rect").data($data);
// Your code here, or choose a preset from above
var colorScale = d3.scale.linear()
.range(['#f2f2f2', 'darkgreen']) // or use hex values
.domain([0, 10]);
var tooltip = d3.select("#playground")
@dervalp
dervalp / grail.js
Last active August 29, 2015 14:00
Api test
//registering a Model in Grail
var grailed = require("grail");
var app = grailed("MyApplication");
app.config({
initialise: function () {
/* Require all configs */
require('./config/moldy.config');
},
@dervalp
dervalp / gist:10850643
Last active August 29, 2015 13:59
IOC
var toto = function (name, $Provider) {
//will be an EntityService
//name is test
};
toto.$DataProvider = "";
IOC.register("Toto")
.define( toto )
.inject({ name: "Test" })
define(["sitecore"], function (_sc) {
_sc.Factories.createBaseComponent({
name: "Buttongroup",
base: "BlockBase",
selector: ".sc-button-group",
attributes: [
{ name: "commands", defaultValue: [] }
],
initialize: function () {
this._super();