Skip to content

Instantly share code, notes, and snippets.

View fdecampredon's full-sized avatar

François de Campredon fdecampredon

  • Fadio IT
  • Marseille
View GitHub Profile
@fdecampredon
fdecampredon / CodeMirror.d.ts
Created October 23, 2012 17:24
TypeScript CodeMirror Definition File
interface CodeMirrorScrollInfo {
x:number;
y:number;
width:number;
height:number;
}
@fdecampredon
fdecampredon / jquery.dynatree.d.ts
Created October 25, 2012 23:56
Dynatree typescript definition
interface JQuery {
dynatree(options?:DynatreeOptions):DynaTree;
dynatree(option?:string,...rest:any[]):any;
}
interface JQueryStatic {
ui:{
dynatree:DynatreeNamespace;
};
}
interface DynaTree {
declare module "libxmljs" {
export function parseXmlString(source:string):XMLDocument;
export function parseHtmlString(source:string):HTMLDocument;
export class XMLDocument {
constructor(version:number, encoding:string);
child(idx:number):Element;
childNodes():Element[];
/*
The MIT License (MIT)
Copyright (c) 2014 François de Campredon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
/*jshint node:true*/
var fs = require('fs'),
path = require('path');
var walk = function(dir, done) {
var results = [];
fs.readdir(dir, function(err, list) {
if (err) return done(err);
var pending = list.length;
if (!pending) return done(null, results);
@fdecampredon
fdecampredon / gist:86ccbba3863bccaec7dd
Last active November 25, 2015 21:58
Obtaining client window size on server
/*jshint node:true*/
var http = require('http');
var fs = require('fs');
var url = require('url');
var querystring = require('querystring');
var head = fs.readFileSync('head.html','UTF-8');
//<head>
// <meta charset="utf-8">
@fdecampredon
fdecampredon / gist:9687b27904d1eb25757a
Last active August 29, 2015 14:09
possible rx-react events integration
// in this first option events handlers are just RxJs functor Subject
// those subject are passed down to the render function and are manually injected into
// the properties of react component
var RxReact = require('rx-react');
var React = require('react');
@fdecampredon
fdecampredon / gist:8b5f537bacb6e2bda99b
Last active August 29, 2015 14:15
Going beyond rx-react
import {FuncSubject} from 'rx-react';
import {Observable} from 'rx';
/**
* Component are just expressed with single function that return an
* RxReact Component instance, instead of taking the props object
* as argument, they take an observable of props.
*
* By default *shouldComponentUpdate* is the one from PureRenderMixin
*/
@fdecampredon
fdecampredon / Contract.ts
Last active August 10, 2019 22:03
Contract programming with typescript and decorators
@In((a: string, b: string) => {
assert(typeof a === 'string');
assert(typeof b === 'string');
assert(a.length > 5);
assert(a.length > 7);
})
@Out((result: string) => {
assert(typeof result === 'string');
assert(a.length > 12);
})
@fdecampredon
fdecampredon / Container.js
Last active August 27, 2017 17:04
redux-relay
import React from 'react';
import { container } from 'redux-relay';
@container({
variablesFromState: (state) => ({myVariable: state.myState})
fragments: {
Relay.QL`
viewer {