Skip to content

Instantly share code, notes, and snippets.

View dralletje's full-sized avatar
🛰️
😱🦁🤨

Michiel Dral dralletje

🛰️
😱🦁🤨
View GitHub Profile
@dralletje
dralletje / flow-cli.js
Created April 8, 2019 17:20
Better flow CLI, most likely outdated
// @flow
let { uniq, flatten } = require('lodash');
let chalk = require('chalk');
let dedent = require('dedent');
let { isEqual, padStart, padEnd, trimEnd } = require('lodash');
let fs = require('fs');
// NOTE CLASSIC
const indent = indentLevel => (...args) => {
import React from 'react';
export class Form extends React.Component {
state = {
has_submitted: false,
submit_error: null,
};
render() {
let { children, onSubmit, conditions } = this.props;
import React from 'react';
import immutagen from 'immutagen';
export let generator_render = (generator_fn) => {
let { Provider, Consumer } = React.createContext();
let render_subchild = (generator, value) => {
let { value: element, next: next_generator } = generator(value);
return <Provider value={{ generator: next_generator }}>{element}</Provider>;
};
import React, { Component } from 'react';
import { isEqual, debounce } from 'lodash';
import yaml from 'js-yaml';
import Measure from 'react-measure';
import styled from 'styled-components';
import uuid from 'uuid/v1';
import md5 from 'md5';
import { Transformation2DMatrix } from './TransformationMatrix.js';
import { DocumentEvent, Absolute, Whitespace, Layer } from './Elements.js';
@dralletje
dralletje / Elements.jsx
Created June 21, 2018 23:48
Voor Timon
import React from 'react';
/*
Simple component that will not render anything.
On mount it will bind to a document event, and it will clean up on unmount
<DocumentEvent
name="scroll"
handler={updateScrollPosition}
/>
*/
'atom-text-editor':
'cmd-;': 'editor:fold-current-row'
'cmd-\'': 'tabs:close-other-tabs'
//let REPORT_TO_PDF_URL = 'http://localhost:5000'; // For testing locally
let REPORT_TO_PDF_URL = 'https://report-to-pdf.herokuapp.com';
let download_pdf_from_html = async ({ html_body, pdf_options, filename }) => {
let resp = await fetch(`${REPORT_TO_PDF_URL}/request_pdf_path`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ html_body, pdf_options, filename }),
// @flow
import React from 'react';
import shallowEqual from 'shallowequal';
/*
// Weird example, but I hope you get the point
<Compose
toggle={fn =>
<State initialValue={false} children={(value, change) => ({ value, change })} />
// @flow
const useful_times = {
ten_am_monday: 1500884100000,
};
// '2017-07-27T21:29:45.301'
const base_time_timestamp = useful_times.ten_am_monday;
const Original_Date = Date;
import React from 'react';
import RNFetchBlob from 'react-native-fetch-blob';
import { EmptyC, Lifecycle } from '@ubutler/utils/MetaComponents';
import { RemoteMethod } from '../../MeteorComponents';
const chatapp_get_jpeg_upload_method = {
remote: (meteor, token) => {
return meteor.method({
name: 'chatapp_get_jpeg_upload',