Skip to content

Instantly share code, notes, and snippets.

@yyyyaaa
yyyyaaa / web-fonts-asset-pipeline.md
Created April 4, 2017 05:12 — forked from anotheruiguy/web-fonts-asset-pipeline.md
Custom Web Fonts and the Rails Asset Pipeline

Web fonts are pretty much all the rage. Using a CDN for font libraries, like TypeKit or Google Fonts, will be a great solution for many projects. For others, this is not an option. Especially when you are creating a custom icon library for your project.

Rails and the asset pipeline are great tools, but Rails has yet to get caught up in the custom web font craze.

As with all things Rails, there is more then one way to skin this cat. There is the recommended way, and then there are the other ways.

The recommended way

Here I will show how to update your Rails project so that you can use the asset pipeline appropriately and resource your files using the common Rails convention.

const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const extractSass = ExtractTextPlugin({
filename: "[name].[contenthash].css",
disable: process.env.NODE_ENV === "development"
});
module.exports = {
entry: '/assets/main.js',
means:
  • - when before Type
  • - when after Type

- A map thunk is a function that returns the map type GraphQLFieldConfigMapThunk = () => GraphQLFieldConfigMap

##################################### type GraphQLSchemaConfig = { query: GraphQLObjectType;

@yyyyaaa
yyyyaaa / permissions.js
Created September 8, 2017 07:39
Graphql permissions
import _ from 'lodash';
const createResolver = (resolver) => {
const baseResolver = resolver;
baseResolver.createResolver = (childResolver) => {
const newResolver = async (parent, args, context) => {
await resolver(parent, args, context);
return childResolver(parent, args, context);
}
return createResolver(newResolver);
@yyyyaaa
yyyyaaa / mutations.js
Created September 8, 2017 07:40
Mutations with permissions
import bcrypt from 'bcrypt';
import jwt from 'jsonwebtoken';
import _ from 'lodash';
import {
requiresAuth,
requiresAdmin,
ensuresSameUser,
} from '../permissions';
@yyyyaaa
yyyyaaa / convert id_rsa to pem
Created September 21, 2017 15:54 — forked from mingfang/convert id_rsa to pem
Convert id_rsa to pem file
openssl rsa -in ~/.ssh/id_rsa -outform pem > id_rsa.pem
chmod 700 id_rsa.pem
@yyyyaaa
yyyyaaa / postgres-brew.md
Created February 25, 2018 02:43 — forked from sgnl/postgres-brew.md
Installing Postgres via Brew (OSX)

Installing Postgres via Brew

Pre-Reqs

Brew Package Manager

In your command-line run the following commands:

  1. brew doctor
  2. brew update
import Emitter from 'wildemitter'
import { isFunction } from 'lodash'
const EVENTS = {
register: '@modals/REGISTER',
show: '@modals/SHOW',
hide: '@modals/HIDE',
destroy: '@modals/DESTROY'
}
@yyyyaaa
yyyyaaa / prefetch.js
Created March 25, 2018 05:18 — forked from acdlite/prefetch.js
Prefetching in React
function prefetch(getKey, getValue, getInitialValue, propName) {
const inFlight = new Set();
const cache = new Map();
return ChildComponent => {
return class extends React.Component {
state = {value: getInitialValue(this.props)};
componentWillReceiveProps(nextProps) {
const key = getKey(nextProps);
if (cache.has(key)) {
// Use cached value
<Breadcrumbs
separator='/'
steps={[
{ label: 'Page A', link: 'path/to/a' },
{ label: 'Page B', link: 'path/to/b' }
]}
current='path/to/b'
/>