Last active
October 15, 2019 04:09
-
-
Save ssmak/607432b1d66401428a7bcf5be316f705 to your computer and use it in GitHub Desktop.
Collections of snippet (Atom).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'.source.js,.source.babel': | |
'Define a module': | |
'prefix': 'xx.angularjs.module' | |
'body': """ | |
const myApp = angular.module('my-app', []); | |
""" | |
'Define a controller': | |
'prefix': 'xx.angularjs.controller' | |
'body': """ | |
myApp.controller('my-ctrl', ($scope) => { | |
}); | |
""" | |
'Define a filter': | |
'prefix': 'xx.angularjs.filter' | |
'body': """ | |
myApp.filter('myFilter', () => { | |
return (val) => { | |
return val; | |
}; | |
}); | |
""" | |
'Define a service': | |
'prefix': 'xx.angularjs.service' | |
'body': """ | |
myApp.service('MyService', ($http) => { | |
return { | |
get: (url) => { | |
return $http.get(url); | |
} | |
} | |
}); | |
""" | |
'Define a factory': | |
'prefix': 'xx.angularjs.factory' | |
'body': """ | |
myApp.factory('MyFactory', ($http) => { | |
return { | |
get: (url) => { | |
return $http.get(url); | |
} | |
} | |
}); | |
""" | |
'Define a directive': | |
'prefix': 'xx.angularjs.directive' | |
'body': """ | |
myApp.directive('myDirective', () => { | |
return { | |
restrict: 'A', | |
template: '<h1>Hello World!</h1>' | |
templateUrl: 'directive.html', | |
replace: false, | |
transclude: false, | |
scope: false, | |
require: ['someOtherDirective'], | |
controller: ($scope, $element, $attrs, $transclude) => { | |
}, | |
priority: 0, | |
terminal: false | |
} | |
}); | |
""" | |
'Define a value': | |
'prefix': 'xx.angularjs.value' | |
'body': """ | |
myApp.value('myValue', { | |
fruit: ['apple', 'orange', 'banana'], | |
fastfood: ['chips', 'coke', 'hamburger'] | |
}); | |
""" | |
'Define a constant': | |
'prefix': 'xx.angularjs.constant' | |
'body': """ | |
myApp.constant('myConstant', { | |
fruit: ['apple', 'orange', 'banana'], | |
fastfood: ['chips', 'coke', 'hamburger'] | |
}); | |
""" | |
'Define a provider': | |
'prefix': 'xx.angularjs.provider' | |
'body': """ | |
myApp.provider('myProvider', () => { | |
this.initCities = () => { | |
console.log(“Initializing Cities…”); | |
}; | |
this.$get = () => { | |
var cities = [“New Delhi”, “Mumbai”, “Kolkata”, “Chennai”]; | |
function addCity(city) { | |
cities.push(city); | |
} | |
function getCities(){ | |
return cities; | |
} | |
return { | |
getCities: getCities, | |
addCity: addCity | |
}; | |
} | |
}); | |
""" | |
'Config an Angular application': | |
'prefix': 'xx.angularjs.config' | |
'body': """ | |
myApp.config((myProvider) => { | |
}); | |
} | |
""" | |
'Run block': | |
'prefix': 'xx.angularjs.run' | |
'body': """ | |
myApp.run((myService, myFactory) => { | |
}); | |
""" | |
'Bootstrap a angular application': | |
'prefix': 'xx.angularjs.bootstrap' | |
'body': """ | |
angular.bootstrap(document, ['my-app']); | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'.source.json': | |
'Basic Babel setting for ES6': | |
'prefix': 'xx.babel.es6' | |
'body': """ | |
{ | |
"presets": ["preset-env"], | |
"minified": true | |
} | |
""" | |
'Basic Babel setting for React': | |
'prefix': 'xx.babel.es6' | |
'body': """ | |
{ | |
"presets": ["preset-react"], | |
"minified": true | |
} | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'.text.md': | |
'New CHANGELOG template': | |
'prefix': 'xx.changelog.template' | |
'body': """ | |
# Changelog | |
All notable changes to this project will be documented in this file. | |
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | |
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | |
## [Unreleased] | |
""" | |
'Unreleased': | |
'prefix': 'xx.changelog.unreleased' | |
'body': """ | |
## [Unreleased] | |
""" | |
'New version': | |
'prefix': 'xx.changelog.version' | |
'body': """ | |
## [x.x.x] - YYYY-mm-yy | |
""" | |
'Event:Added': | |
'prefix': 'xx.changelog.event.added' | |
'body': """ | |
### Added | |
""" | |
'Event:Changed': | |
'prefix': 'xx.changelog.events.changed' | |
'body': """ | |
### Changed | |
""" | |
'Event:Deprecated': | |
'prefix': 'xx.changelog.events.deprecated' | |
'body': """ | |
### Deprecated | |
""" | |
'Event:Removed': | |
'prefix': 'xx.changelog.events.removed' | |
'body': """ | |
### Removed | |
""" | |
'Event:Fixed': | |
'prefix': 'xx.changelog.events.fixed' | |
'body': """ | |
### Fixed | |
""" | |
'Event:Security': | |
'prefix': 'xx.changelog.events.security' | |
'body': """ | |
### Security | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'.source.sass, .source.css.less, .source.css, .text.html.basic': | |
'Media query.': | |
'prefix': 'xx.css.media-query' | |
'body': """ | |
@media screen and (min-width: 480px) { | |
} | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'.text.html.basic': | |
'Exclude from preprocess': | |
'prefix': 'xx.preprocess.html.exclude' | |
'body': """ | |
<!-- @exclude --> | |
<!-- @endexclude --> | |
""" | |
'If-condition': | |
'prefix': 'xx.preprocess.html.if' | |
'body': """ | |
<!-- @if ENV='uat' --> | |
<!-- @echo 'somethings' --> | |
<!-- @endif --> | |
""" | |
'If-define': | |
'prefix': 'xx.preprocess.html.ifdefine' | |
'body': """ | |
<!-- @ifdef DEBUG --> | |
<!-- @echo 'somethings' --> | |
<!-- @endif --> | |
""" | |
'Include external file': | |
'prefix': 'xx.preprocess.html.include' | |
'body': """ | |
<!-- @include welcome_message.txt --> | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'.text.html.php,.source.js,.source.babel': | |
'Exclude from preprocess': | |
'prefix': 'xx.preprocess.php.exclude' | |
'body': """ | |
// @exclude | |
// @endexclude | |
""" | |
'If-condition': | |
'prefix': 'xx.preprocess.php.if' | |
'body': """ | |
// @if ENV='uat' | |
// @echo 'somethings' | |
// @endif | |
""" | |
'If-define': | |
'prefix': 'xx.preprocess.php.ifdefine' | |
'body': """ | |
// @ifdef DEBUG | |
// @echo 'somethings' | |
// @endif | |
""" | |
'Include external file': | |
'prefix': 'xx.preprocess.php.include' | |
'body': """ | |
// @include welcome_message.txt | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'.source.js': | |
'Basic Gulp template': | |
'prefix': 'xx.gulp' | |
'body': """ | |
const gulp = require('gulp'); | |
const clean = require('gulp-clean'); | |
const npmDist = require('gulp-npm-dist'); | |
const preprocess = require('gulp-preprocess'); | |
const uglify = require('gulp-uglify'); | |
const htmlmin = require('gulp-htmlmin'); | |
const gulpSequence = require('gulp-sequence'); | |
const pump = require('pump'); | |
const argv = require('yargs').argv; | |
gulp.task('clean', () => { | |
return pump([ | |
gulp.src(['build'], { read: false }), | |
clean() | |
]); | |
}); | |
gulp.task('copy.source', () => { | |
return pump([ | |
gulp.src(['.htaccess', 'favicon.ico', 'index.html', 'components/**/*', 'controllers/**/*', 'modules/**/*', 'resources/**/*', 'services/**/*', '!**/*.babel', '!**/*.map', '!**/*.scss'], { base: '.' }), | |
gulp.dest('build') | |
]); | |
}); | |
gulp.task('copy.library', () => { | |
return pump([ | |
gulp.src(npmDist({ | |
copyUnminified: false | |
}), { base: './node_modules' }), | |
gulp.dest('build/node_modules') | |
]); | |
}); | |
gulp.task('copy.library.all', () => { | |
return pump([ | |
gulp.src(npmDist({ | |
copyUnminified: true | |
}), { base: './node_modules' }), | |
gulp.dest('build/node_modules') | |
]); | |
}); | |
gulp.task('optimize.js', () => { | |
return pump([ | |
gulp.src(['build/**/*.js', '!build/node_modules/**/*']), | |
uglify({ mangle: false }), | |
gulp.dest((file) => { | |
return file.base; | |
}) | |
]); | |
}); | |
gulp.task('optimize.html', () => { | |
return pump([ | |
gulp.src(['build/**/*.html']), | |
htmlmin({ collapseWhitespace: true }), | |
gulp.dest((file) => { | |
return file.base; | |
}) | |
]); | |
}); | |
gulp.task('build.uat', gulpSequence('clean', ['copy.source', 'copy.library.all'])); | |
gulp.task('build.pro', gulpSequence('clean', ['copy.source', 'copy.library'], 'optimize.js', 'optimize.html')); | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'.text.html.basic': | |
'Minimum HTML5 template': | |
'prefix': 'xx.html' | |
'body': """ | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<base href="/"> | |
<meta charset="utf-8" /> | |
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> | |
<meta http-equiv="x-ua-compatible" content="ie=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<meta name="description" content=""> | |
<meta name="keywords" content=""> | |
<meta name="author" content=""> | |
<meta http-equiv="cache-control" content="max-age=0" /> | |
<meta http-equiv="cache-control" content="no-cache" /> | |
<meta http-equiv="expires" content="0" /> | |
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" /> | |
<meta http-equiv="pragma" content="no-cache" /> | |
<link rel="icon" href="favicon.ico"> | |
<title></title> | |
<!--[if lt IE 9]> | |
<script src="node_modules/html5shiv/dist/html5shiv.min.js"></script> | |
<script src="node_modules/respondjs/lib/respond.js"></script> | |
<![endif]--> | |
</head> | |
<body> | |
</body> | |
</html> | |
""" | |
'Comman meta tags': | |
'prefix': 'xx.html.meta-tags.common' | |
'body': """ | |
<meta charset="utf-8" /> | |
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> | |
<meta http-equiv="x-ua-compatible" content="ie=edge" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1" /> | |
<meta name="description" content="" /> | |
<meta name="keywords" content="" /> | |
<meta name="author" content="" /> | |
""" | |
'No-cache meta tags': | |
'prefix': 'xx.html.meta-tags.no-cache' | |
'body': """ | |
<meta http-equiv="cache-control" content="max-age=0" /> | |
<meta http-equiv="cache-control" content="no-cache" /> | |
<meta http-equiv="expires" content="0" /> | |
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" /> | |
<meta http-equiv="pragma" content="no-cache" /> | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'.source.css.less': | |
'Mark this .less file as auto-compile.': | |
'prefix': 'xx.less.auto-compile' | |
'body': '// out: ${1:outfile.css}, compress: ${2:true | false}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'.source.js,.source.babel': | |
'Basic class of React component': | |
'prefix': 'xx.react.component' | |
'body': """ | |
'use strict'; | |
import React from 'react'; | |
import ReactDom from 'react-dom'; | |
export default class <ClassName> extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = {}; | |
} | |
componentDidMount() { | |
// call on component init | |
} | |
componentWillUnmount() { | |
// call on component destroy | |
} | |
componentWillUpdate(nextProps, nextState) { | |
// call on component update | |
} | |
componentDidUpdate(prevProps, prevState) { | |
// call on component after update | |
} | |
render() { | |
return ( | |
<!-- the class name should be unique, so no conflict with others components or global style --> | |
<div className="b4d98f78-bffc-4534-bd87-ea5c4306b950"> | |
<!-- place content here --> | |
<link rel="stylesheet" href="<the_component_stylesheet>" /> | |
</div> | |
); | |
} | |
} | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'.source.js': | |
'Basic template of RequireJS config.': | |
'prefix': 'xx.requirejs.config' | |
'body': """ | |
require.config({ | |
baseUrl: "/node_modules", | |
paths: { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min", | |
"bootstrap": "https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min", | |
"less": "https://cdnjs.cloudflare.com/ajax/libs/less.js/2.7.1/less.min" | |
} | |
}); | |
requirejs(["jquery", "less"], function() { | |
requirejs(["bootstrap"], function() { | |
console.log('All libraries are loaded!'); | |
}); | |
}); | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'.source.scss': | |
'List': | |
'prefix': 'xx.scss.list' | |
'body': """ | |
$list: (value1, value2, value3); | |
""" | |
'Map': | |
'prefix': 'xx.scss.map' | |
'body': """ | |
$map: (key1: value1, key2: value2, key3: value3); | |
""" | |
'IfElse': | |
'prefix': 'xx.scss.ifelse' | |
'body': """ | |
@if $type == ocean {} @else {} | |
""" | |
'For': | |
'prefix': 'xx.scss.for' | |
'body': """ | |
@for $i from 1 through 3 { | |
} | |
""" | |
'Each': | |
'prefix': 'xx.scss.each' | |
'body': """ | |
@each $animal in puma, sea-slug, egret, salamander {} | |
""" | |
'While': | |
'prefix': 'xx.scss.while' | |
'body': """ | |
@while $i > 0 {} | |
""" | |
'Mixins': | |
'prefix': 'xx.scss.mixins' | |
'body': """ | |
@mixin transform($property) { | |
-webkit-transform: $property; | |
-ms-transform: $property; | |
transform: $property; | |
} | |
.box { @include transform(rotate(30deg)); } | |
""" | |
'Function::map-get': | |
'prefix': 'xx.scss.func.map-get' | |
'body': """ | |
map-get($map, $key) | |
""" | |
'Function::map-merge': | |
'prefix': 'xx.scss.func.map-merge' | |
'body': """ | |
map-merge($map1, $map2) | |
""" | |
'Function::map-remove': | |
'prefix': 'xx.scss.func.map-remove' | |
'body': """ | |
map-remove($map, $keys…) | |
""" | |
'Function::map-keys': | |
'prefix': 'xx.scss.func.map-keys' | |
'body': """ | |
map-keys($map) | |
""" | |
'Function::map-values': | |
'prefix': 'xx.scss.func.map-values' | |
'body': """ | |
map-values($map) | |
""" | |
'function::map-has-key': | |
'prefix': 'xx.scss.func.map-has-key' | |
'body': """ | |
map-has-key($map, $key) | |
""" | |
'function::keywords': | |
'prefix': 'xx.scss.func.keywords' | |
'body': """ | |
keywords($args) | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'.source.js,.source.babel': | |
'Basic template of SystemJS config.': | |
'prefix': 'xx.systemjs.config' | |
'body': """ | |
SystemJS.config({ | |
baseURL: "/", | |
defaultJSExtensions: false, | |
paths: { | |
"npm:": "node_modules/" | |
}, | |
map: { | |
"jquery": "npm:jquery/dist/jquery.min.js" | |
}, | |
meta: { | |
"*.css": { | |
loader: "css" | |
} | |
} | |
}); | |
""" | |
'Import library.': | |
'prefix': 'xx.systemjs.import' | |
'body': """ | |
SystemJS.import('library') | |
.then((object) => {}) | |
.catch(err => {}) | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'.source.json': | |
'Basic TypeScript setting': | |
'prefix': 'xx.tsc.config' | |
'body': """ | |
{ | |
"compilerOptions": { | |
"module": "commonjs", | |
"target": "es5", | |
"noImplicitAny": true, | |
"sourceMap": true, | |
"alwaysStrict": true | |
} | |
} | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment