Skip to content

Instantly share code, notes, and snippets.

View xonlly's full-sized avatar
:shipit:

Marvin SANT xonlly

:shipit:
View GitHub Profile
@xonlly
xonlly / ApolloQueryPromise.js
Created January 24, 2018 15:17
ApolloQueryPromise(client<context>, query<string>, variables<object>, options<object>).then(...)
import PropTypes from 'prop-types';
/*
ApolloQueryPromise(client<context>, query<string>, variables<object>, {
skip: ownProps => ownProps.skip,
})
.then((data, res) => console.log('data', data, res))
.catch(error => { ... });
*/
const ApolloQueryPromise = (client, query, variables = {}, config = {}) =>
@xonlly
xonlly / Apollo query component.jsx
Last active November 23, 2017 13:29
<ApolloQuery query={...} parser={data => data} variables={{ a: 'hello' }}>{parsedData => <div>{...}</div>}</ApolloQuery>
import { Component } from 'react';
import PropTypes from 'prop-types';
// wait apollo 2.1
export default class ApolloQuery extends Component {
state = { data: undefined, rest: {}, loading: false };
componentWillMount() {
const { query, variables } = this.props;
this.query(query, variables);
@xonlly
xonlly / jsconfig.json
Created September 7, 2017 14:09
jsconfig for react jsx project
{
"compilerOptions": {
"jsx": "react",
// This must be specified if "paths" is set
"baseUrl": ".",
// Relative to "baseUrl"
"paths": {
// exemple: "*": ["*", "web_modules/*", "web_modules/shared/*", "test/*"]
}
}
@xonlly
xonlly / visualStudioCode.json
Last active August 31, 2017 13:22
Ma config visual studio code
{
"workbench.colorTheme": "One Dark Pro",
"atomKeymap.promptV3Features": true,
"editor.multiCursorModifier": "ctrlCmd",
"editor.formatOnPaste": true,
"workbench.iconTheme": "material-icon-theme",
"prettier.eslintIntegration": true,
"prettier.trailingComma": "all",
"prettier.singleQuote": true,
"workbench.startupEditor": "newUntitledFile",
@xonlly
xonlly / resize.js
Last active July 3, 2017 13:57
Change Quality, maxSize from binary image. ( manage image rotation )
import originalInkjet from 'inkjet';
const EXIF_TRANSFORMS = {
1: { rotate: 0, flip: false },
2: { rotate: 0, flip: true },
3: { rotate: Math.PI, flip: false },
4: { rotate: Math.PI, flip: true },
5: { rotate: Math.PI * 1.5, flip: true },
6: { rotate: Math.PI * 0.5, flip: false },
7: { rotate: Math.PI * 0.5, flip: true },
{
"version":"0.1",
"uploadKeys":[
{
"name":"EMDR",
"key":"CREST"
}
],
"rowsets":[
{
#!/bin/bash
echo "Welcome to listen script"
echo "Check if process restart"
MJ_APIKEY_PUBLIC="*****"
MJ_APIKEY_PRIVATE="*****"
SENDER_EMAIL="contact@*****.com"
RECIPIENT_EMAIL="devteck@*****.com"
@xonlly
xonlly / getWeekNumber.js
Created January 11, 2016 11:25
Get the week number by date.
function getWeekNumber(d) {
d = new Date(+d);
d.setHours(0,0,0);
d.setDate(d.getDate() + 4 - (d.getDay()||7));
var yearStart = new Date(d.getFullYear(),0,1);
var weekNo = Math.ceil(( ( (d - yearStart) / 86400000) + 1)/7);
return [d.getFullYear(), weekNo];
}
// Exemple:
@xonlly
xonlly / getDayFromWeekNumber.js
Created January 11, 2016 11:21
Get first and last day by a week number.
function weekToDate(year, wn, dayNb){
var j10 = new Date( year,0,10,12,0,0),
j4 = new Date( year,0,4,12,0,0),
mon1 = j4.getTime() - j10.getDay() * 86400000;
return [
new Date(mon1 + ((wn - 2) * 7 + dayNb) * 86400000),
new Date(mon1 + ((wn - 1) * 7 + dayNb-1) * 86400000),
]
};