Skip to content

Instantly share code, notes, and snippets.

View alexandrebodin's full-sized avatar

Alexandre BODIN alexandrebodin

View GitHub Profile
@alexandrebodin
alexandrebodin / script.sh
Last active August 29, 2015 14:08
jenkins configuration
# Move into the jenkins directory
cd /var/lib/jenkins
#test config params
[ -z "$jenkins_config_repo" ] && echo "Need to set jenkins_config_repo" && exit 1
[ -z "$jenkins_email" ] && echo "Need to set jenkins_email" && exit 1
#test if init necessary
if [ ! -d ".git" ];
then
import _ from 'lodash/fp';
const mapValuesWithKey = _.mapValues.convert({ cap: false});
const internals = {
/**
* Returns a function that transforms an object's subObjects based on a mapping configuration
* @param Object mapping a mapping configuration
* @return Function transformer a transformer function
*/
const emailSpecification = email => {
const expression = 'user.email === email';
return {
isSatisfiedBy(user) {
return eval(expression);
}
};
// Welcome! require() some modules from npm (like you were using browserify)
// and then hit Run Code to run your code on the right side.
// Modules get downloaded from browserify-cdn and bundled in your browser.
var Immutable = require('immutable');
const b = new Immutable.Record({
id: null,
name: null,
});
@alexandrebodin
alexandrebodin / index.js
Last active March 17, 2017 01:09
pipe & branch async code
import _ from 'lodash/fp';
const pipe = (...list) =>
(args) =>
_.flatten(list).reduce((p, fn) => p.then(fn), Promise.resolve(args))
const branch = (...list) =>
(args) => Promise.all(list.map(fn => fn(args)))
import Task from 'data.task';
import R from 'ramda';
const run = t => {
return t.fork(
err => console.log('err', err),
R.tap(console.log)
);
}
@alexandrebodin
alexandrebodin / index.js
Created September 1, 2016 07:58
dataloader batching without caching
import DataLoader from 'dataloader';
const getBatchUsers = (ids = []) => {
// runs sth like
// SELECT * FROM users WHERE id IN (:ids)
};
// cache is disabled
const userLoader = new DataLoader(getBatchUsers, {cache: false});
const phoneToString = phone => `${phone.prefix} ${phone.number}`;
const phones = [
{
prefix: '+33',
number: '102219123',
},
{
prefix: '+33',
number: '1111111111',
@alexandrebodin
alexandrebodin / index.js
Last active September 27, 2016 14:04
applicative functors
import fs from 'fs';
import { add, prop, lift } from 'ramda';
import Task from 'data.task';
import Box from './Box';
import Maybe from './Maybe';
var marked = require('marked');
var TerminalRenderer = require('marked-terminal');
marked.setOptions({
// Define custom renderer
@alexandrebodin
alexandrebodin / index.js
Last active October 4, 2017 20:17
addEntity to knex query with simplicity and clean code
var R = require('ramda');
var knex = require('knex')({
client: 'pg',
connection: {
host: 'localhost',
port: '35432',
database: 'vamos',
password: 'vamos',
user: 'vamos',
}