Skip to content

Instantly share code, notes, and snippets.

@ziazek
Last active January 9, 2019 04:19
Show Gist options
  • Save ziazek/1ebc1faea9bbcf3cf3fa0237dd70f970 to your computer and use it in GitHub Desktop.
Save ziazek/1ebc1faea9bbcf3cf3fa0237dd70f970 to your computer and use it in GitHub Desktop.
'.source.js':
'log with label':
'prefix': 'llog'
'body': "console.log('$1', $1);"
'import Lodash':
'prefix': 'lodash'
'body': 'import _ from "lodash";'
'import Moment':
'prefix': 'moment'
'body': 'import moment from "moment";'
'import Link':
'prefix': 'link'
'body': 'import { Link } from "react-router-dom";'
'import Snackbar':
'prefix': 'snackbar'
'body': 'import { openSnackbar } from "../../components/Snackbar";'
'import graphql':
'prefix': 'graphql'
'body': """
import { graphql } from "react-apollo";
import gql from "graphql-tag";
"""
'import Formik':
'prefix': 'formik'
'body': """
import { withFormik } from "formik";
import * as Yup from "yup";
"""
'toast':
'prefix': 'toast'
'body': """
Toast.show({
text: "Donation Completed.",
buttonText: "Okay",
type: "success",
textStyle: bold,
duration: 3000
});
"""
'toast Error':
'prefix': 'toasterr'
'body': """
Toast.show({
text: "Something went wrong.",
buttonText: "Okay",
type: "danger",
textStyle: bold,
duration: 3000
});
"""
'snackbar Error':
'prefix': 'snackerr'
'body': """
openSnackbar({
type: "error",
message: "Event was not found."
});
"""
'snackbar Success':
'prefix': 'snacksuc'
'body': """
openSnackbar({
type: "success",
message: "Order note created."
});
"""
'get (Axios)':
'prefix': 'get'
'body': """
get("$1")
.then(({ data }) => {
if (data.successful) {
$2setDonorsList(data.donorsList);
}
setLoading(false);
})
.catch(({ message }) => {
history.push("/error", { message });
});
"""
'post (Axios)':
'prefix': 'post'
'body': """
post("/$1", formData).then(({ data }) => {
if (data.successful) {
Toast.show({
text: "$2",
buttonText: "Okay",
type: "success",
textStyle: bold,
duration: 5000,
position: "top"
});
$3
}
$4setLoading(false);
});
// .catch(({ message }) => {
// history.push("/error", { message });
// });
"""
'withFormik':
'prefix': 'withFormik'
'body': """
withFormik({
${1:isInitialValid: props => props.attendee.valid,}
mapPropsToValues: props =>
{
surname: "",
given_name: "",
email: ""
},$2
validationSchema: Yup.object().shape({
surname: Yup.string()
.min(2, "too short")
.required("Required"),
}),
handleSubmit: (values, formikBag) => {
$3
}
}),
"""
'.source.jsx':
'comment':
'prefix': 'com'
'body': "{/* $1 */}"
'comment multiline':
'prefix': 'comm'
'body': """
{/*
$1
*/}
"""
'ClassName':
'prefix': 'class'
'body': "className={classes.$1}"
'Stateless React Component':
'prefix': 'stateless'
'body': """
import React from 'react';
import { compose } from 'recompose';
const ${1:ComponentName} = props => {
const { ${2:something} } = props;
return (
<div>
{ $2 }
</div>
)
};
const enhance = compose();
export default enhance(${1:ComponentName});
"""
'Stateless React Component - Material UI':
'prefix': 'stateless'
'body': """
import React from "react";
import { compose } from "recompose";
import { withStyles } from "@material-ui/core/styles";
import Grid from "@material-ui/core/Grid";
import Paper from "@material-ui/core/Paper";
const styles = () => ({});
const ${1: ComponentName} = props => {
const { classes } = props;
return (
<Grid container spacing={24}>
<Grid item xs={12}>
<Paper className={classes.paper}>
<h1 style={{ textAlign: "center", marginTop: 20 }}>${1: ComponentName}</h1>
</Paper>
</Grid>
</Grid>
);
};
const enhance = compose(withStyles(styles));
export default enhance(${1: ComponentName});
"""
'withState':
'prefix': 'with'
'body': "withState('$1', 'set$1', $2),"
'Material UI import':
'prefix': 'muii'
'body': '''
import $1 from '@material-ui/core/$1';
'''
'Material UI Icon import':
'prefix': 'muic'
'body': '''
import $1Icon from '@material-ui/icons/$1';
'''
'GraphQL import':
'prefix': 'graph'
'body': '''
import { graphql } from "react-apollo";
import gql from "graphql-tag";
'''
'.text.elixir':
'Elixir block echo':
'prefix': 'pe'
'body': '<%= $1 %>'
'Elixir block silent':
'prefix': 'pee'
'body': '<% $1 %>'
'.string.html':
'Elixir block echo':
'prefix': 'pe'
'body': '<%= $1 %>'
'Elixir block silent':
'prefix': 'pee'
'body': '<% $1 %>'
'.source.elixir':
'import ShorterMaps':
'prefix': 'shorter'
'body': 'import ShorterMaps'
'Map':
'prefix': 'm'
'body': '%{${1:key}${2:\:} ${3:value}}'
'IO Puts':
'prefix': 'put'
'body': 'IO.puts("$1")'
'IO inspect':
'prefix': 'ins'
'body': 'IO.puts("$1 #{inspect($1)}")'
'IO Puts and Inspect':
'prefix': 'iins'
'body': 'IO.inspect($1, label: "$1")'
'Apex':
'prefix': 'ap'
'body': 'Apex.ap({"$1", $1})'
'Logger info':
'prefix': 'log'
'body': 'Logger.info "[#{ABO.Helpers.now} | :${1:<function_name>}] ${2:thing}: #{inspect(${2:thing})}"'
'Logger error':
'prefix': 'err'
'body': 'Logger.error "[#{ABO.Helpers.now} | :${1:<function_name>}] ${2:thing}: #{inspect(${2:thing})}"'
'Controller test':
'prefix': 'testc'
'body': """
test "$1", %{conn: conn} do
$2
end
"""
# Your snippets
#
# Atom snippets allow you to enter a simple prefix in the editor and hit tab to
# expand the prefix into a larger code block with templated values.
#
# You can create a new snippet in this file by typing "snip" and then hitting
# tab.
#
# An example CoffeeScript snippet to expand log to console.log:
#
# '.source.coffee':
# 'Console log':
# 'prefix': 'log'
# 'body': 'console.log $1'
#
# Each scope (e.g. '.source.coffee' above) can only be declared once.
#
# This file uses CoffeeScript Object Notation (CSON).
# If you are unfamiliar with CSON, you can read more about it in the
# Atom Flight Manual:
# http://flight-manual.atom.io/using-atom/sections/basic-customization/#_cson
@ziazek
Copy link
Author

ziazek commented Nov 27, 2017

screen shot 2017-11-27 at 9 53 09 am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment