Skip to content

Instantly share code, notes, and snippets.

@goldsborough
Created February 10, 2017 13:35
Show Gist options
  • Save goldsborough/4e87acf829a677dbf7be95c021061d01 to your computer and use it in GitHub Desktop.
Save goldsborough/4e87acf829a677dbf7be95c021061d01 to your computer and use it in GitHub Desktop.
# 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:
# https://atom.io/docs/latest/using-atom-basic-customization#cson
'.source.go':
'Println':
'prefix': 'pl'
'body': """fmt.Println($1)"""
'Printf':
'prefix': 'pf'
'body': """fmt.Printf(\"$1\", $2)"""
'Method':
'prefix': 'method'
'body': """
func (${1:rec} *${2:T}) ${3:Name}()${4: int} {
return ${5:code}
}
"""
'Function':
'prefix': 'fn'
'body': """
func ${1:name}()${2: int} {
return ${5:code}
}
"""
'.source.gfm':
'Python Snippet':
'prefix': 'py'
'body': '```python\n$1\n```'
'C++ Snippet':
'prefix': 'cpp'
'body': '```cpp\n$1\n```'
'Shell Snippet':
'prefix': 'shell'
'body': '```shell\n$1\n```'
'Python In':
'prefix': 'in'
'body': 'In [${1:0}]: $2'
'Python Out':
'prefix': 'out'
'body': 'Out [${1:0}]: $2'
'.source.cpp, .source.c':
'Cout':
'prefix': 'cout'
'body': 'std::cout << "$1" << std::endl;'
'Include Guard':
'prefix': 'guard'
'body': """
#ifndef $1_HPP
#define $1_HPP
$2
#endif /* $1_HPP*/
"""
'Print Functionality':
'prefix': 'print'
'body': """
void print() {
std::cout << std::endl;
}
template <typename Head, typename... Tail>
void print(Head&& head, Tail&&... tail) {
std::cout << std::forward<Head>(head);
if (sizeof...(tail)) std::cout << ", ";
print(std::forward<Tail>(tail)...);
}
template <typename Iterator>
void printall(Iterator begin, Iterator end) {
while (begin != end) {
std::cout << *begin;
if (++begin == end) break;
std::cout << ", ";
}
std::cout << std::endl;
}
template <typename Range>
void printall(const Range& range) {
using std::begin;
using std::end;
printall(begin(range), end(range));
}
template <typename Map>
void printmap(const Map& map) {
for (const auto& pair : map) {
std::cout << pair.first << " -> " << pair.second << "\n";
}
std::cout << std::flush;
}
"""
'Algorithm Boilerplate':
'prefix': 'algo'
'body': """
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <initializer_list>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
$1
auto main() -> int {
}
"""
'Template Forward':
'prefix': 'fwd'
'body': 'std::forward<${1:T}>(${2:value})'
'Static Cast':
'prefix': 'static'
'body': 'static_cast<${1:T}>(${2:value})'
'Reinterpret Cast':
'prefix': 'reinterpet'
'body': 'reinterpret_cast<${1:T}>(${2:value})'
'Dynamic Cast':
'prefix': 'dynamic'
'body': 'dynamic_cast<${1:T}>(${2:value})'
'Clang Format off':
'prefix': 'off'
'body': '// clang-format off'
'Clang Format on':
'prefix': 'on'
'body': '// clang-format on'
'Template Class':
'prefix': 'tc'
'body': """
template<typename ${1:T}>
class ${2:Name} {
public:
$2();
private:
};
"""
'Class':
'prefix': 'class'
'body': """
class ${1:Name} {
public:
$1();
private:
};
"""
'Template Function':
'prefix': 'tf'
'body': """
template<typename ${1:T}>
${2:void} ${3:function}(${4:const T&}) {
// ${5:code}
}
"""
'Namespace':
'prefix': 'ns'
'body': """
namespace ${1:Name} {
$2
}
"""
'Function Documentation':
'prefix': 'fdoc'
'body': """
/**
* ${1:Brief}
*
* ${2:Details}
*
* \\\\param ${3:arg1} ${4:description}
* \\\\param ${5:arg1} ${6:description}
* \\\\param ${7:arg1} ${8:description}
*
* \\\\return $9
*/
"""
'Setter Documentation':
'prefix': 'sdoc'
'body': """
/**
* ${1:Brief}
*
* \\\\param ${2:arg1} ${3:description}
*
* \\\\return $4
*/
"""
'Getter Documentation':
'prefix': 'gdoc'
'body': """
/**
* ${1:Brief}
*/
"""
'Class Documentation':
'prefix': 'cdoc'
'body': """
/**
* ${1:Brief}
*
* ${2:Details}
*/
"""
'Test':
'prefix': 't'
'body': """
TEST($1, $2) {
}
"""
'.text.tex.latex':
'Slide':
'prefix': 'slide'
'body': """
\\\\begin{slide}{$1}
$2
\\\\end{slide}
"""
'Input':
'prefix': 'input'
'body': '\\\\input{$1}'
'Use Package':
'prefix': 'usepackage'
'body': '\\\\usepackage{$1}'
'Tikzpicture':
'prefix': 'tikz'
'body': """
\\\\begin{tikzpicture}
$1
\\\\end{tikzpicture}
"""
'For Loop':
'prefix': 'foreach'
'body': """
\\\\foreach \\\\${1:i} in {${2:0}, ..., ${3:n}} {
$4
}
"""
'Vertical Space':
'prefix': 'vspace'
'body': '\\\\vspace{$1cm}'
'Horizontal Space':
'prefix': 'hspace'
'body': '\\\\hspace{$1cm}'
'New Command':
'prefix': 'newcommand'
'body': '\\\\newcommand{\\\\$1}[$2]{$3}'
'New Environment':
'prefix': 'newenv'
'body': """
\\\\newenviroment{$1}[$2]
{
$3
}
{
$4
}
"""
'Bold Text':
'prefix': 'tb'
'body': '\\\\textbf{$1}'
'Only Overlay':
'prefix': 'only'
'body': '\\\\only<$1> { $2 }'
'Onslide Overlay':
'prefix': 'onslide'
'body': '\\\\onslide<$1> { $2 }'
'.source.cmake':
'Template':
'prefix': 'template'
'body': """
###########################################################
## CMAKE SETUP
###########################################################
cmake_minimum_required(VERSION 3.2)
project($1)
###########################################################
## INCLUDES
###########################################################
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/${2:include})
###########################################################
## SOURCES
###########################################################
set($3_SOURCES
)
###########################################################
## TARGETS
###########################################################
add_library($1 SHARED ${$3_SOURCES})
add_executable($1 ${$3_SOURCES})
###########################################################
## COMPILER FLAGS
###########################################################
target_link_libraries($1 )
target_link_libraries($1 )
target_compile_options($1 PUBLIC )
target_compile_options($1 PUBLIC )
"""
'.text.html.basic':
'Jinja extends':
'prefix': 'ext'
'body': '{% extends \"$1.html\" %}'
'Jinja if':
'prefix': 'if'
'body': """
{% if $1 %}
$2
{% endif %}
"""
'Jinja else':
'prefix': 'else'
'body': '{% else %}'
'Jinja elif':
'prefix': 'elif'
'body': '{% elif $1 %}'
'Jinja include':
'prefix': 'include'
'body': '{% include "$1" %}'
'Jinja import':
'prefix': 'import'
'body': '{% from "$1" import $2 with context %}'
'Jinja for':
'prefix': 'for'
'body': """
{% for $1 in $2 %}
$3
{% endfor %}
"""
'Jinja block':
'prefix': 'block'
'body': """
{% block $1 %}
$3
{% endblock %}
"""
'.source.python':
'Python Boilerplate':
'prefix': 'boilerplate'
'body': """
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
'Multiline string':
'prefix': 'ms'
'body': '"""$1"""'
'Constructor':
'prefix': 'init'
'body': 'def __init__(self):\n'
'Function Documentation':
'prefix': 'fdoc'
'body': """
\"\"\"
${1:Brief}
${2:Details}
Args:
${3:args} (${4:type}): ${5:description}
Returns:
$6
\"\"\"
"""
'.source.js':
'Custom for':
'prefix': 'cfor'
'body': """
for (var ${1:i} = 0; $1 < $2; ++$1) {
$3
}
"""
'Optimized for':
'prefix': 'ofor'
'body': """
for (var ${1:i} = 0, stop = $2; $1 < stop; ++$1) {
$3
}
"""
'JSDoc Function':
'prefix': 'doc'
'body': """
/**
* ${1:Brief}
*
* ${2:Description}
*
* @param { }
* @param { }
*
* @see
*
* @return
*/
"""
'Assert':
'prefix': 'assert'
'body': 'console.assert(${1:condition})'
'JSDoc File':
'prefix': 'fdoc'
'body': """
/**
* @file ${1:Description}
* @author Peter Goldsborough <[email protected]>
* @license MIT
*/
"""
'Test':
'prefix': 'test'
'body': """
test('${1:that...}', t => {
$2
});
"""
'.source.qml':
'Log':
'prefix': 'log'
'body': 'console.log("$1");'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment