Skip to content

Instantly share code, notes, and snippets.

@yoadsn
yoadsn / attempt.js
Created November 16, 2016 20:46
Resolve both Global and MongoDB ids - attempt
import composeWithMongoose from 'graphql-compose-mongoose';
import { composeWithRelay, fromGlobalId } from 'graphql-compose-relay';
import { MyModel } from './dbSchema.js'; // mongoose models..
const mongoOrGlobalIdToMongoId = (_id) => {
let resultId = _id;
if (isString(_id) && !/^[a-fA-F0-9]{24}$/.test(_id)) {
const { type, id } = fromGlobalId(_id);
if (type && /^[a-zA-Z]*$/.test(type)) {
resultId = id;
@yoadsn
yoadsn / airtableSlackHistory.js
Created November 10, 2016 12:04
Extracting AirTable changes from Slack
import _ from 'lodash';
import { WebClient as SlackWebClientCreator } from '@slack/client'
const airtableActivitySlackChannelId = 'C30RWN4JY'; // The Slack ID of the channel
const slackWebClient = new SlackWebClientCreator(process.env.SLACK_API_TOKEN)
const recordFromLinkRegexp = /[^\/]+?$/ // then entire match
const tableFromLinkRegexp = /\/([^\/]+?)\/[^\/]+?$/ // the first capture group
const getSlackChannelHistory = async (channelId, since) => {
return new Promise((res, rej) => {
{
"text": "Yoad Snapir updated 1 record in table *Images* in Wescover Data Store",
"bot_id": "B30PP75EE",
"attachments": [{
"author_name": "Yoad Snapir",
"title": "BestImageEver",
"id": 1,
"title_link": "https:\/\/airtable.com\/tblykBG6t4nC3tEGF\/recbEsFKWqHgYdN3X",
"author_icon": "https:\/\/static.airtable.com\/images\/userIcons\/user_icon_4@3x.png",
"color": "faa200",
@yoadsn
yoadsn / tabsView.jsx
Created March 5, 2016 20:10
Example of routing + redux
import styles from "./styles.css"
import React from "react"
import { AppBar, Tabs, Tab } from "material-ui"
import { Link } from "react-router"
import { map, addIndex } from "ramda"
import { actions } from "./update"
export const view = ({ data: model, dispatch, children, location, ...props }) =>
<div className={styles.root} {...props}>