Skip to content

Instantly share code, notes, and snippets.

@mwmcode
Last active October 23, 2016 14:43
Show Gist options
  • Select an option

  • Save mwmcode/a45acc7db19b4bae2d07 to your computer and use it in GitHub Desktop.

Select an option

Save mwmcode/a45acc7db19b4bae2d07 to your computer and use it in GitHub Desktop.
Atom Snippets
## PHP & Laravel
'.php':
'Blade errors list':
'prefix': 'lerr'
'body': """
@if( $status )
<div class="alert alert-info" role="alert"> {{$status}} </div>
@endif
@if ($errors->any())
<ul class="alert alert-danger">
@foreach($errors->all() as $error)
<li> {{ $error }} </li>
@endforeach
</ul>
@endif
"""
'Laravel Register Form':
'prefix': 'rform'
'body': """
@include('errors.list')
<form action="{{ route('${1:route.here}') }}" method="POST">
{!! csrf_field() !!}
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" name="name" value="{{ old('name') }}"/>
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="email" class="form-control" name="email" value="{{ old('email') }}"/>
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control" name="password" value="{{ old('password') }}"/>
</div>
<div class="form-group">
<label for="password_confirmation">Password</label>
<input type="password" class="form-control" name="password_confirmation" value="{{ old('password_confirmation') }}"/>
</div>
<!--Submit button -->
<div class="form-group">
<button type="submit" class="btn btn-primary btn-block">Create User</button>
</div>
</form>
"""
'PHP public method':
'prefix': 'meth'
'body': """
public function ${1:}(${2:})
{
${3:}
}
"""
#######
## HTML.
'.html':
'HTML Space':
'prefix': 'space'
'body': '&nbsp;'
'BootTextField':
'prefix': 'txtf'
'body': """
<div class="form-group">
<label for="${1:this}">${2:this}</label>
<input type="text" class="form-control" name="${1:this}" id="${1:this}" value="{{ old('${1:this}') }}"/>
</div>
"""
'Blade csrf token':
'prefix': 'token'
'body': """
{!! csrf_field() !!}
${1:{!! method_field("${2:DELETE}") !!\\}}
"""
'Input hidden field':
'prefix': 'hidd'
'body': '<input type="hidden" name="_method" value="${1:PATCH}">'
'Glyphicon span':
'prefix': 'glyph'
'body': ' <span class="glyphicon glyphicon-${1:ok}"></span> '
## CDNS ##
'CDN jQuery':
'prefix': 'jquery'
'body': '<script src="https://code.jquery.com/jquery-2.1.4.min.js"> </script>'
'CDN Bootstrap CSS':
'prefix': 'bootc'
'body': '<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">'
'CDN Bootstrap JS':
'prefix': 'bootj'
'body': '<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"> </script>'
'CDN Vue JS':
'prefix': 'vue'
'body': '<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.10/vue.js"> </script>'
'ReactJSX src':
'prefix': 'jsx'
'body': "<script type='text/jsx;harmony=true' ${1:src='${2:path/here}'}></script>"
###############
## JavaScript
'.source.js':
'jQuery $.get':
'prefix': 'get'
'body': """
\$.get('${1:url}', function(response) {
${2:if (response != 0)}
}.bind(this));
"""
'jQuery $.post':
'prefix': 'post'
'body': """
\$.post('${1:url}', {${2:key: val}}, function(response) {
${3:if (response != 0)}
}.bind(this));
"""
'jQuery AJAX':
'prefix': 'ajax'
'body': """
\$.ajax({
url: '${1:url}',
type: '${2:post}',
data: ${3:data},
datatype: "json",
context: this,
success: function(response) {
console.log("success!");
},
error : function(response) {
alert(response);
}
});
"""
'Self-invoking function':
'prefix': 'sif'
'body': """
(function () {
${1:}
})();
"""
'JS Method':
'prefix': 'mtn'
'body': """
${1:}: function(${2:}) {
${3:}
}
"""
'JS Comment':
'prefix': 'comm'
'body': """
/*----------------------------------------
| ${1:}
|----------------------------------------*/
"""
'Webpack Config':
'prefix': 'webpc'
'body': """
import webpack from 'webpack';
import path from 'path';
export default {
debug: true,
devtool: 'source-map',
target: 'web',
entry: [
'${1:./src/index}'
],
output: {
path: __dirname + '${2:/dist}',
publicPath: '/',
filename: '${3:bundle.js}'
},
devServer: {
contentBase: '${4:./src}'
},
module: {
loaders: [
{
exclude: '/node_module/',
loader: 'babel',
query: {
presets: ['es2015', 'react']
}
}
]
}
}
"""
'New Vue instance':
'prefix': 'newv'
'body': """
new Vue({
el: '${1:scopeEl}',
data: {
filters: {
},
},
computed: {
},
methods: {
},
});
"""
## NODE JS
##########
'Node JS Require':
'prefix': 'nreq'
'body': "var ${1:} = require('${2:${1:}}')${3:};"
'JS Module Export':
'prefix': 'exp'
'body': "module.exports = ${1:};"
'Callback function':
'prefix': 'cbf'
'body': """
function(${1:}) {
${2:}
}${3:}
"""
## ReactJS
'ReactJS Class':
'prefix': 'rcla'
'body': """
var ${1:Counter} = React.createClass({
render: function() {
return {
${2:<div />}
};
}
});
ReactDOM.render(<${1:Counter} />, document.body);
"""
###############
## Python
'.source.python':
'ipdb':
'prefix': 'pdb'
'body': 'import ipdb; ipdb.set_trace()'
'Python instantiator':
'prefix': 'pyinit'
'body': """
def __init__(self, ${1:name}, ${2:developer}, ${3:price}, ${4:**kwargs}):
self.${1:name} = ${1:name}
self.${2:developer} = ${2:developer}
self.${3:price} = ${3:price}
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment