Skip to content

Instantly share code, notes, and snippets.

@i5on9i
Last active March 15, 2018 04:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save i5on9i/f5363a5170db9dbfb61be3aa8f2e1815 to your computer and use it in GitHub Desktop.
Save i5on9i/f5363a5170db9dbfb61be3aa8f2e1815 to your computer and use it in GitHub Desktop.
- path : c:\Users\<user_name>\AppData\Roaming\Code\User\snippets\mysnippet.code-snippets
{
// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
// Placeholders with the same ids are connected.
// Example:
// "Print to console": {
// "scope": "javascript,typescript",
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
"Create React class template": {
"scope": "javascript,typescript",
"prefix": "classtemplate",
"body": [
"import * as Styles from \"./${1:className}.scss\";",
"import * as React from \"react\";",
"\n",
"export interface ${1:className}Props extends React.Props<any>{",
"}",
"export interface ${1:className}State { ",
"}",
"\n",
"export default class ${1:className} extends React.Component<${1:className}Props, ${1:className}State> {",
"\tconstructor(props: any){",
"\t\tsuper(props);",
"\t\tthis.state = {",
"\t\t}",
"\t}",
"\n",
"\trender(){",
"\t\treturn(",
"\t\t\t<div className=\"\">",
"\t\t\t</div>",
"\t\t)",
"\t}",
"\tcomponentDidMount(){",
"\t}",
"}"
],
"description": "Create a new React class"
},
"fori": {
"scope": "javascript,typescript,typescriptreact",
"prefix": "forii",
"body": [
"const arrLen = ${1:array}.length;",
"for (let ${2:i} = 0; ${2:i} < arrLen; ${2:i}++) {",
"\tconst d = ${1:array}[${2:i}];",
"\t$0",
"}",
],
"description": "for(i..)"
},
//--- php
"private function": {
"scope": "php",
"prefix": "pf",
"body": [
"private function ${1:funcname}($$param){",
"\t$0",
"}"
],
"description": "private function template"
},
"foreach": {
"scope": "php",
"prefix": "foree",
"body": [
"foreach ($${1:$array} as $${2:$item => $$value}) {",
"\t$0",
"}",
],
"description": "foreach"
},
"db builder": {
"scope": "php",
"prefix": "dbbuilder",
"body": [
"$0",
"$$ret = DB::table(DB::raw(\"({$${1:firstSubQuery}->toSql()}) AS tt1\"))",
"\t->mergeBindings($${1:firstSubQuery})",
"\t->leftJoin(",
"\t\tDB::raw(\"({$${2:secondSubQuery}->toSql()}) AS tt2\" ),",
"\t\t'tt1.column_name', '=', 'tt2.column_name'",
"\t)->mergeBindings($${2:secondSubQuery})",
"\t->where([",
"\t\t['tt1.column_name', '=', value]",
"\t])->select(",
"\t\t'tt1.column_name', 'tt2.column_name'",
"\t)->get();",
],
"description": "DB Builder"
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment