Skip to content

Instantly share code, notes, and snippets.

@dfang
Last active November 28, 2016 09:38
Show Gist options
  • Save dfang/794908bd5b290f360f1d8a2b5a6a524d to your computer and use it in GitHub Desktop.
Save dfang/794908bd5b290f360f1d8a2b5a6a524d to your computer and use it in GitHub Desktop.
this is settings backed up by atom sync-settings package
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to make opened Markdown files always be soft wrapped:
#
# path = require 'path'
#
# atom.workspaceView.eachEditorView (editorView) ->
# editor = editorView.getEditor()
# if path.extname(editor.getPath()) is '.md'
# editor.setSoftWrap(true)
# Your keymap
#
# Atom keymaps work similarly to stylesheets. Just as stylesheets use selectors
# to apply styles to elements, Atom keymaps use selectors to associate
# keystrokes with events in specific contexts.
#
# You can create a new keybinding in this file by typing "key" and then hitting
# tab.
#
# Here's an example taken from Atom's built-in keymap:
#
# '.editor':
# 'enter': 'editor:newline'
#
# '.workspace':
# 'ctrl-P': 'core:move-up'
# 'ctrl-p': 'core:move-down'
#
[
{
"name": "about",
"version": "1.5.3"
},
{
"name": "advanced-open-file",
"version": "0.16.4"
},
{
"name": "archive-view",
"version": "0.61.1"
},
{
"name": "atom-alignment",
"version": "0.12.1"
},
{
"name": "atom-beautify",
"version": "0.29.10"
},
{
"name": "atom-dark-syntax",
"version": "0.27.0",
"theme": "syntax"
},
{
"name": "atom-dark-ui",
"version": "0.52.0",
"theme": "ui"
},
{
"name": "atom-light-syntax",
"version": "0.28.0",
"theme": "syntax"
},
{
"name": "atom-light-ui",
"version": "0.44.0",
"theme": "ui"
},
{
"name": "atom-snippets-for-devs",
"version": "0.9.0"
},
{
"name": "atomizr",
"version": "0.20.1"
},
{
"name": "autocomplete-atom-api",
"version": "0.10.0"
},
{
"name": "autocomplete-css",
"version": "0.11.2"
},
{
"name": "autocomplete-html",
"version": "0.7.2"
},
{
"name": "autocomplete-plus",
"version": "2.31.1"
},
{
"name": "autocomplete-snippets",
"version": "1.11.0"
},
{
"name": "autoflow",
"version": "0.27.0"
},
{
"name": "autoprefixer",
"version": "3.2.0"
},
{
"name": "autosave",
"version": "0.23.1"
},
{
"name": "background-tips",
"version": "0.26.1"
},
{
"name": "base16-tomorrow-dark-theme",
"version": "1.1.0",
"theme": "syntax"
},
{
"name": "base16-tomorrow-light-theme",
"version": "1.1.1",
"theme": "syntax"
},
{
"name": "bookmarks",
"version": "0.41.0"
},
{
"name": "bracket-matcher",
"version": "0.82.1"
},
{
"name": "command-palette",
"version": "0.38.0"
},
{
"name": "deprecation-cop",
"version": "0.54.1"
},
{
"name": "dev-live-reload",
"version": "0.47.0"
},
{
"name": "editorconfig",
"version": "1.4.1"
},
{
"name": "encoding-selector",
"version": "0.22.0"
},
{
"name": "erb-snippets",
"version": "1.1.0"
},
{
"name": "exception-reporting",
"version": "0.39.0"
},
{
"name": "file-icons",
"version": "1.7.20"
},
{
"name": "find-and-replace",
"version": "0.201.0"
},
{
"name": "fuzzy-finder",
"version": "1.3.0"
},
{
"name": "git-diff",
"version": "1.1.0"
},
{
"name": "go-to-line",
"version": "0.31.0"
},
{
"name": "grammar-selector",
"version": "0.48.1"
},
{
"name": "image-view",
"version": "0.58.2"
},
{
"name": "incompatible-packages",
"version": "0.26.1"
},
{
"name": "keybinding-cheatsheet",
"version": "0.1.1"
},
{
"name": "keybinding-resolver",
"version": "0.35.0"
},
{
"name": "language-babel",
"version": "2.43.0"
},
{
"name": "language-c",
"version": "0.52.1"
},
{
"name": "language-clojure",
"version": "0.21.0"
},
{
"name": "language-coffee-script",
"version": "0.47.2"
},
{
"name": "language-csharp",
"version": "0.12.1"
},
{
"name": "language-css",
"version": "0.37.1"
},
{
"name": "language-docker",
"version": "1.1.7"
},
{
"name": "language-elixir",
"version": "0.16.0"
},
{
"name": "language-gfm",
"version": "0.88.0"
},
{
"name": "language-git",
"version": "0.15.0"
},
{
"name": "language-go",
"version": "0.42.1"
},
{
"name": "language-haml",
"version": "0.24.0"
},
{
"name": "language-html",
"version": "0.45.1"
},
{
"name": "language-hyperlink",
"version": "0.16.0"
},
{
"name": "language-java",
"version": "0.23.0"
},
{
"name": "language-javascript",
"version": "0.119.0"
},
{
"name": "language-json",
"version": "0.18.2"
},
{
"name": "language-jsx",
"version": "0.1.1"
},
{
"name": "language-less",
"version": "0.29.5"
},
{
"name": "language-make",
"version": "0.22.2"
},
{
"name": "language-mustache",
"version": "0.13.0"
},
{
"name": "language-nginx",
"version": "0.6.2"
},
{
"name": "language-objective-c",
"version": "0.15.1"
},
{
"name": "language-perl",
"version": "0.35.0"
},
{
"name": "language-php",
"version": "0.37.2"
},
{
"name": "language-property-list",
"version": "0.8.0"
},
{
"name": "language-python",
"version": "0.45.0"
},
{
"name": "language-ruby",
"version": "0.69.0"
},
{
"name": "language-ruby-on-rails",
"version": "0.25.0"
},
{
"name": "language-sass",
"version": "0.56.0"
},
{
"name": "language-shellscript",
"version": "0.22.4"
},
{
"name": "language-source",
"version": "0.9.0"
},
{
"name": "language-sql",
"version": "0.23.0"
},
{
"name": "language-text",
"version": "0.7.1"
},
{
"name": "language-todo",
"version": "0.28.0"
},
{
"name": "language-toml",
"version": "0.18.0"
},
{
"name": "language-xml",
"version": "0.34.9"
},
{
"name": "language-yaml",
"version": "0.26.0"
},
{
"name": "line-ending-selector",
"version": "0.5.0"
},
{
"name": "link",
"version": "0.31.1"
},
{
"name": "linter",
"version": "1.11.18"
},
{
"name": "linter-eslint",
"version": "7.2.4"
},
{
"name": "markdown-preview",
"version": "0.158.0"
},
{
"name": "metrics",
"version": "0.53.1"
},
{
"name": "my-atom-snippets",
"version": "0.0.0"
},
{
"name": "notifications",
"version": "0.65.0"
},
{
"name": "odoo-atom-snippets",
"version": "1.0.0"
},
{
"name": "odoo-snippets",
"version": "0.3.0"
},
{
"name": "one-dark-syntax",
"version": "1.3.0",
"theme": "syntax"
},
{
"name": "one-dark-ui",
"version": "1.5.0",
"theme": "ui"
},
{
"name": "one-light-syntax",
"version": "1.3.0",
"theme": "syntax"
},
{
"name": "one-light-ui",
"version": "1.5.0",
"theme": "ui"
},
{
"name": "open-on-github",
"version": "1.2.0"
},
{
"name": "open-terminal-here",
"version": "2.1.4"
},
{
"name": "package-generator",
"version": "1.0.0"
},
{
"name": "package-settings",
"version": "1.1.0"
},
{
"name": "phoenix-elixir-snippets",
"version": "0.4.0"
},
{
"name": "python-autopep8",
"version": "0.1.3"
},
{
"name": "settings-view",
"version": "0.241.2"
},
{
"name": "snippets",
"version": "1.0.2"
},
{
"name": "solarized-dark-syntax",
"version": "1.0.2",
"theme": "syntax"
},
{
"name": "solarized-light-syntax",
"version": "1.0.2",
"theme": "syntax"
},
{
"name": "spell-check",
"version": "0.67.1"
},
{
"name": "status-bar",
"version": "1.4.1"
},
{
"name": "styleguide",
"version": "0.47.0"
},
{
"name": "symbols-view",
"version": "0.113.0"
},
{
"name": "sync-settings",
"version": "0.7.2"
},
{
"name": "tabs",
"version": "0.100.2"
},
{
"name": "timecop",
"version": "0.33.2"
},
{
"name": "tree-view",
"version": "0.208.2"
},
{
"name": "update-package-dependencies",
"version": "0.10.0"
},
{
"name": "welcome",
"version": "0.34.0"
},
{
"name": "whitespace",
"version": "0.33.0"
},
{
"name": "wrap-guide",
"version": "0.38.1"
}
]
{
"": {
"rb$": "source.ruby"
},
"atom-beautify": {
"general": {
"_analyticsUserId": "7bd24f42-4525-4758-b5d4-0be70ce06930"
},
"python": {
"autopep8_path": "/usr/local/var/pyenv/shims/autopep8",
"beautify_on_save": false,
"indent_size": 4,
"indent_with_tabs": false,
"max_line_length": 79
},
"xml": {
"beautify_on_save": true
}
},
"core": {
"automaticallyUpdate": false,
"disabledPackages": [
"language-chef"
],
"ignoredNames": [
".git",
".hg",
".svn",
".DS_Store",
"._*",
"Thumbs.db",
".log",
".sass-cache",
"*.pyc"
],
"themes": [
"atom-dark-ui",
"atom-dark-syntax"
]
},
"editor": {
"backUpBeforeSaving": true,
"fontSize": 12,
"showIndentGuide": true,
"showInvisibles": true,
"zoomFontWhenCtrlScrolling": true
},
"exception-reporting": {
"userId": "66c9b31f-9467-fdf8-2c58-7c282f850703"
},
"file-types": {
"\\.hbs$": "text.html.htmlbars"
},
"metrics": {
"userId": "0bb9a34bbd80810feab0f9ca32a27a21b3f8612b"
},
"sync-settings": {},
"tree-view": {
"hideIgnoredNames": true
},
"welcome": {
"showOnStartup": false
}
}
# 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.
#
# tips 1:
# snippets 出不来, 很有可能是语法错误, command+option+i 打开console 就可以看到错误
# tips 2:
# 当你不知道用source.ruby 还是source.rb 时,先Open the Developer Tools (Cmd+Alt+I on OS X), 再打开Editor: Log Cursor Scope
# https://discuss.atom.io/t/how-do-you-configure-use-snippets/335/29?u=dfang
# tips 3:
# snippets 的prefix 区分大小写
# tips 4:
# 已经固定下来的snippet 转移到 my-snippets 那个pacakge 里了
# 如何快速打开, open atom settings, search my snippets, click open in atom
'.text.html':
'HTML5 Skeleton':
'prefix': 'html5skel'
'body': '<!doctype html>'
'Snippet Name':
'prefix': 'bower'
'body': '''
<script src='${0:./bower_components/}${1:}'></script>
'''
'.source.js':
'myProviderDemo':
'prefix': 'myProvider'
'body': '''
'use strict';
/**
* @ngdoc service
* @name myApp.myProvider
* @description
* # myProvider
* Provider in the myApp.
*/
angular.module('myApp')
.provider('myProvider', function () {
// Private variables
var salutation = 'Hello';
// Private constructor
function Greeter() {
this.greet = function () {
return salutation;
};
}
// Public API for configuration
this.setSalutation = function (s) {
salutation = s;
};
// Method for instantiating
this.$get = function () {
return new Greeter();
};
});
'''
'myFactoryDemo':
'prefix': 'myFactory'
'body': '''
'use strict';
/**
* @ngdoc service
* @name myApp.myFactory
* @description
* # myFactory
* Factory in the myApp.
*/
angular.module('myApp')
.factory('myFactory', function () {
// Service logic
// ...
var meaningOfLife = 42;
// Public API here
return {
someMethod: function () {
return meaningOfLife;
}
};
});
'''
'myServiceDemo':
'prefix': 'myService'
'body': '''
'use strict';
/**
* @ngdoc service
* @name myApp.myService
* @description
* # myService
* Service in the myApp.
*/
angular.module('myApp')
.service('myService', function () {
// AngularJS will instantiate a singleton by calling "new" on this function
});
'''
'myControllerDemo':
'prefix': 'myController'
'body': '''
'use strict';
/**
* @ngdoc function
* @name myApp.controller:MycontrollerCtrl
* @description
* # MycontrollerCtrl
* Controller of the myApp
*/
angular.module('myApp')
.controller('MycontrollerCtrl', function ($scope) {
$scope.awesomeThings = [
'HTML5 Boilerplate',
'AngularJS',
'Karma'
];
});
'''
'myFilterDemo':
'prefix': 'myFilter'
'body': '''
'use strict';
/**
* @ngdoc filter
* @name myApp.filter:myFilter
* @function
* @description
* # myFilter
* Filter in the myApp.
*/
angular.module('myApp')
.filter('myFilter', function () {
return function (input) {
return 'myFilter filter: ' + input;
};
});
'''
'myConstantDemo':
'prefix': 'myConstant'
'body': '''
'use strict';
/**
* @ngdoc service
* @name myApp.myConstant
* @description
* # myConstant
* Constant in the myApp.
*/
angular.module('myApp')
.constant('myConstant', 42);
'''
'myValueDemo':
'prefix': 'myValue'
'body': '''
'use strict';
/**
* @ngdoc service
* @name myApp.myValue
* @description
* # myValue
* Value in the myApp.
*/
angular.module('myApp')
.value('myValue', 42);
'''
'app.controller':
'prefix': 'ctrl'
'body': '''
App.controller('Ctrl', ['$scope', function($scope) {
}])
'''
'Manula bootstrap angular app':
'prefix': 'mbng'
'body': '''
angular.element(document).ready(function() {
angular.bootstrap(document, ['myApp']);
});
'''
'angular config $routeProvider demo':
'prefix': 'ng-route-demo'
'body': '''
.config(['$routeProvider', function($routeProvider){
$routeProvider.
when('/', {
controller: 'ListCtrl',
resolve: {
recipes: {
function(){
return RecipeLoader();
}
}
},
templateUrl: 'views/list.html'
}).when('/new', {
controller: 'NewCtrl',
templateUrl: '/views/recipeForm.html'
}).otherwise({
redirectTo: '/'
})
}]);
'''
'angular controler demo':
'prefix': 'controller_demo'
'body': '''
app.controller('ViewCtrl', ['$scope', '$location', 'recipe', function($scope, $location, recipe){
$scope.recipe = recipe;
$scope.edit = function(){
$location.path('/edit/' + recipe.id);
}
}])
'''
'$http signature':
'prefix': '_$http'
'body': '''
$http({
method: string,
url: string,
params: object
data: string or object,
headers: object,
transformRequest: function transform(data, headersGetter) or an array of functions,
transformResponse: function transform(data, headersGetter) or an array of functions,
cache: boolean or Cache object,
timeout: number,
withCredentials: boolean
})
'''
'directive signature':
'prefix': '_directive'
'body': '''
var app = angualr.module('app', []);
app.directive('namespaceDirectiveName', function factory(injectables) {
var directiveDefinitionObject = {
// 一些选项是互斥的, 大部分是可选的,
restrict: string,
priority: number,
template: string,
templateUrl: string,
replace: bool,
transclude: bool,
scope: bool or object,
controller: function controllerConstructor($scope, $element, $attrs, $transclude),
requrie: string,
link: function postLink(scope, iElement, iAttrs){ ........... },
compile: function compile(tElement, tAttrs, transclude) {
return function (scope, element, attrs) {
pre: function preLink(scope, iElement, iAttrs, controller) { ......... },
post: function preLink(scope, iElement, iAttrs, controller) { ......... },
}
}
};
return directiveDefinitionObject;
})
'''
'.source.ruby':
'do':
'prefix': 'do'
'body': '''
do
end
'''
'respond_to':
'prefix': 'respond_to'
'body': '''
respond_to :html, :json, :js, :xml
'''
'module for include':
'prefix': 'hello'
'body': '''
module Base
module ClassMethods
end
module InstanceMethods
end
def self.included(receiver)
receiver.extend ClassMethods
receiver.send :include, InstanceMethods
end
end
'''
'attr':
'prefix': 'hello'
'body': 'Hello World!'
'skip_before_action':
'prefix': 'skip_before_action'
'body': '''
# http://api.rubyonrails.org/classes/ActionController/RequestForgeryProtection.html
skip_before_action :verify_authenticity_token if :json_request?
'''
'simple_form_for':
'prefix': 'simple_form_for'
'body': '''
= simple_form_for @user, html: { class: 'form-horizontal' } do |f|
'''
'simple_nested_form_for':
'prefix': 'simple_nested_form_for'
'body': '''
= simple_nested_form_for @user, html: { class: 'form-inline' } do |f|
'''
'inherited resource defaults':
'prefix': 'defaults'
'body': '''
defaults :resource_class => User, :collection_name => 'users', :instance_name => 'user'
'''
'devise_for routes':
'prefix': 'devise_for'
'body': '''
devise_for :users, controllers: {
registrations: 'users/registrations',
sessions: 'users/sessions',
passwords: 'users/passwords',
confirmations: 'users/confirmations',
omniauth_callbacks: 'users/authentications'
}
devise_for :admin_users, controllers: { sessions: 'admin/sessions' }
devise_scope :user do
get 'users/sign_up/:type' => 'users/registrations#new', as: :sign_up
end
resources :authentications, only: :destroy, controllers: 'users/authentications'
'''
'AASM and symbolize column':
'prefix': 'aasm'
'body': '''
include AASM
symbolize :state, in: [ :pending, :confirmed ], scopes: :shallow, methods: true, default: :pending
aasm column: :state do
state :pending, initial: true
state :confirmed
event :confirm do
transitions from: :pending, to: :confirmed
end
end
'''
'mount_image_version':
'prefix': 'mount_image_version'
'body': '''
include ImageVersion
mount_image_version :image
'''
'.source.coffee':
'coffee version iife':
'prefix': 'ciife'
'body': '''
do ->
'use strict'
$ ->
# code here
'''
'Validtor':
'prefix': 'validator'
'body': '''
class @NewPasswordValidator
constructor: ->
@validate()
validate: ->
$('.new-password-form').validate
rules:
'user[mobile_phone]':
required: true
remote:
url: '/validations/validate_mobile_phone_on_update_registration_info'
data:
mobile_phone: () ->
return $( "#user_mobile_phone" ).val()
'user[captcha]':
required: true
minlength: 6
maxlength: 6
remote:
url: '/validations/validate_captcha_on_registration'
data:
mobile_phone: () ->
return $( "#user_mobile_phone" ).val()
captcha: () ->
return $( "#user_captcha" ).val()
messages:
'user[mobile_phone]':
remote: '该手机号码不存在'
'user[captcha]':
remote: '验证码无效'
errorPlacement: (error, element) ->
if element.attr("name") == "user[captcha]"
error.addClass('error-block').appendTo( element.parents(".form-group") )
else
error.insertAfter(element)
new NewPasswordValidator
'''
'.source.go':
'Snippet Name':
'prefix': ':'
'body': ':= '
/*
* Your Stylesheet
*
* This stylesheet is loaded when Atom starts up and is reloaded automatically
* when it is changed.
*
* If you are unfamiliar with LESS, you can read more about it here:
* http://www.lesscss.org
*/
.tree-view {
}
.editor {
}
.editor .cursor {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment