Skip to content

Instantly share code, notes, and snippets.

View yyx990803's full-sized avatar

Evan You yyx990803

View GitHub Profile
@yyx990803
yyx990803 / async.js
Created August 8, 2014 19:03
Simple helper for async tests in Jasmine 1.3 that mimics 2.0 and Mocha
/**
* Jasmine 1.3 async helper
*/
function async (run) {
return function () {
var done = false
waitsFor(function () { return done })
run(function () { done = true })
}
@yyx990803
yyx990803 / vue.JSON-tmLanguage
Created October 1, 2014 20:58
Syntax highlighting / language support for Vue.js single-HTML-file components
{
"name": "Vue Component",
"uuid": "2627aff3-9590-433e-8d6a-2e2603de23f8",
"scopeName": "text.html.basic",
"fileTypes": ["vue"],
"patterns": [
{
"endCaptures": {
"1": {
"name": "punctuation.definition.tag.end.html"
@yyx990803
yyx990803 / vue.tmLanguage
Created October 2, 2014 07:40
Vue component syntax definition, which embedded highlight for Stylus, Sass, Less, Jade & CoffeeScript.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>fileTypes</key>
<array>
<string>vue</string>
</array>
<key>name</key>
<string>Vue Component</string>
var vm = new Vue({
components: {
example: {
data: function () {
return { a: 1 }
}
}
}
})
@yyx990803
yyx990803 / API options
Last active August 29, 2015 14:20
UglifyJS options for minifying Vue application
compress: {
pure_funcs: [
'_.log',
'_.warn',
'_.assertAsset',
'enableDebug'
]
}
@yyx990803
yyx990803 / bench.js
Created May 31, 2015 04:17
orderBy benchmark
// vue internals
var _ = require('../src/util')
var Path = require('../src/parsers/path')
// original implementation using native sort
var original = function (arr, sortKey, reverse) {
if (!sortKey) {
return arr
}
var order = 1
@yyx990803
yyx990803 / Material-Theme.tmTheme
Last active August 29, 2015 14:25
Material Theme color scheme modified for JavaScriptNext
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="2.4">
<dict>
<key>author</key>
<string>Mattia Astorino (http:&#x2f;&#x2f;astorinomattia.it)</string>
<key>name</key>
<string>Material Theme</string>
<key>semanticClass</key>
@yyx990803
yyx990803 / pre-commit.sh
Last active October 22, 2018 20:52
pre-commit hook for Vue.js
#!/usr/bin/env bash
# get files to be linted
FILES=$(git diff --cached --name-only | grep -E '^src|^test/unit/specs|^test/e2e')
# lint them if any
if [[ $FILES ]]; then
./node_modules/.bin/eslint $FILES
fi
@yyx990803
yyx990803 / data.js
Last active November 2, 2015 20:17
var object = {
message: 'Hello world!'
}
<div id=”example”>
{{ message }}
</div>