snippets [Rust Snippets] Rust编程lang #rust

[Rust Snippets] Rust编程lang #rust

rust.snippets
#################
# Rust Snippets #
#################

# Functions
snippet fn "Function definition"
	fn ${1:function_name}(${2})${3} {
		${0}
	}
snippet pfn "Function definition"
	pub fn ${1:function_name}(${2})${3} {
		${0}
	}
snippet test "Unit test function"
	#[test]
	fn ${1:test_function_name}() {
		${0}
	}
snippet bench "Bench function" b
	#[bench]
	fn ${1:bench_function_name}(b: &mut test::Bencher) {
		b.iter(|| {
			${0}
		})
	}
snippet new "Constructor function"
	pub fn new(${2}) -> ${1:Name} {
		$1 { ${3} }
	}
snippet main "Main function"
	pub fn main() {
		${0}
	}
snippet let "let variable declaration with type inference"
	let ${1} = ${2};
snippet lett "let variable declaration with explicit type annotation"
	let ${1}: ${2} = ${3};
snippet letm "let mut variable declaration with type inference"
	let mut ${1} = ${2};
snippet lettm "let mut variable declaration with explicit type annotation"
	let mut ${1}: ${2} = ${3};
snippet pri "print!"
	print!("${1}");
snippet pri, "print! with format param"
	print!("${1}{${2}}", ${3});
snippet pln "println!"
	println!("${1}");
snippet pln, "println! with format param"
	println!("${1}{${2}}", ${3});
snippet fmt "format!"
	format!("${1}{${2}}", ${3});

# Modules
snippet ec "extern crate"
	extern crate ${1:sync};
snippet ecl "extern crate log"
	#[macro_use]
	extern crate log;
snippet mod
	mod ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} {
		${0}
	} /* $1 */
snippet testmod "Test module" b
	#[cfg(test)]
	mod tests {
		use super::${1:*};

		test${0}
	}
# Attributes
snippet allow "allow lint attribute" b
	#[allow(${1:unused_variable})]
snippet cfg "cfg attribute" b
	#[cfg(${1:target_os = "linux"})]
snippet feat "feature attribute" b
	#![feature(${1:plugin})]
snippet der "#[derive(..)]" b
	#[derive(${1:Debug})]
snippet attr "#[..]" b
	#[${1:inline}]
snippet crate "Define create meta attributes"
	// Crate name
	#![crate_name = "${1:crate_name}"]
	// Additional metadata attributes
	#![desc = "${2:Descrption.}"]
	#![license = "${3:BSD}"]
	#![comment = "${4:Comment.}"]
	// Specify the output type
	#![crate_type = "${5:lib}"]
# Common types
snippet opt "Option<T>"
	Option<${1:i32}>
snippet res "Result<T, E>"
	Result<${1:~str}, ${2:()}>
# Control structures
snippet if
	if ${1} {
		${0:${VISUAL}}
	}
snippet ife "if / else"
	if ${1} {
		${2:${VISUAL}}
	} else {
		${0}
	}
snippet el "else"
	else {
		${0:${VISUAL}}
	}
snippet eli "else if"
	else if ${1} {
		${0:${VISUAL}}
	}
snippet mat "match pattern"
	match ${1} {
		${2} => ${3}
	}
snippet case "Case clause of pattern match"
	${1:_} => ${2:expression}
snippet loop "loop {}" b
	loop {
		${0:${VISUAL}}
	}
snippet wh "while loop"
	while ${1:condition} {
		${0:${VISUAL}}
	}
snippet for "for ... in ... loop"
	for ${1:i} in ${2} {
		${0}
	}
# TODO commenting
snippet todo "TODO comment"
	// [TODO]: ${0:Description}
snippet fixme "FIXME comment"
	// FIXME: $0
# Struct
snippet st "Struct definition"
	struct ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} {
		${0}
	}
snippet impl "Struct/Trait implementation"
	impl ${1:Type/Trait}${2: for ${3:Type}} {
		${0}
	}
snippet stn "Struct with new constructor"
	pub struct ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} {
		${0}
	}

	impl $1 {
		pub fn new(${2}) -> Self {
			$1 { ${3} }
		}
	}
snippet type "Type alias"
	type ${1:NewName} = $2;
snippet enum "enum definition"
	enum ${1:Name} {
		${2},
	}
# Traits
snippet trait "Trait definition"
	trait ${1:Name} {
		${0}
	}
snippet drop "Drop trait implementation (destructor)"
	impl Drop for ${1:Name} {
		fn drop(&mut self) {
			${0}
		}
	}
# Statics
snippet ss "static string declaration"
	static ${1}: &'static str = "${0}";
snippet stat "static item declaration"
	static ${1}: ${2:usize} = ${0};
# Concurrency
snippet scoped "spawn a scoped thread"
	thread::scoped(${1:move }|| {
		${0}
	});
snippet spawn "spawn a thread"
	thread::spawn(${1:move }|| {
		${0}
	});
snippet chan "Declare (Sender, Receiver) pair of asynchronous channel()"
	let (${1:tx}, ${2:rx}): (Sender<${3:i32}>, Receiver<${4:i32}>) = channel();
# Testing
snippet as "assert!"
	assert!(${1:predicate});
snippet ase "assert_eq!"
	assert_eq!(${1:expected}, ${2:actual});
# Implementations
snippet asref "AsRef trait implementation"
	impl AsRef<${1:Ref}> for ${2:Type} {
		fn as_ref(&self) -> &${3:$1} {
			&self.${0:field}
		}
	}
snippet asmut "AsMut trait implementation"
	impl AsMut<${1:Ref}> for ${2:Type} {
		fn as_mut(&mut self) -> &mut ${3:$1} {
			&mut self.${0:field}
		}
	}

snippets Windows常规路径和命令

Windows Genereal路径和命令

windowscommandpath
Then, a nice trick I learned from Vincent Houze, in Explorer go to: 
`C:\Users\YOURUSERNAME\AppData\Roaming\Microsoft\Windows\SendTo` 
Copy your two new TD desktop shortcuts here. 
I rename them to start with an underscore, so they appear in the top of your Send To: contextmenu.

snippets WP CLI Cheetsheet

WP CLI Cheetsheet.md
# wp-cli


Install:

    brew install homebrew/php/wp-cli
    
Upgrade:

    brew upgrade wp-cli   

Check version

    wp --info

## Issues

### Error establishing a database connection
PHP not set to MAMP. `which php` to check then edit zshrc path something like this

```
PATH=~/git-home/bin:/Applications/MAMP/bin/php/php5.6.10/bin/:/Applications/MAMP/bin/php/php5.6.10/:/Applications/MAMP/Library/bin:$PATH:
```


## Install Mulit-site

```
wpc [sitename] && cd [sitename]
wp core multisite-install --title="PHP 5.6.10" --admin_user="root" --admin_password="pw" --admin_email="zackary.allnutt@gmail.com"

```
Create and serve
wp config create --dbname="Horizon" --dbuser="root" --dbpass="pw"
wp db create
wp core install --url=localhost:8080 --title=title --admin_user=admin --admin_password=pw --admin_email=example@example
Change urls
wp option update home 'http://localhost'
wp option update siteurl 'http://localhost'
Install on server
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp

snippets Testkommando

test.txt
hej

snippets 不同的git添加方式

常用的git add方法

different-git-add
git add <list-of-files> # add the list of files
git add --all		# add all files
git add *.txt		# add all files endswith ".txt" in current directory
git add docs/*.txt	# add all files endswith ".txt" in docs directory
git add docs		# add all files in docs directory
git add .		# add current directory
git add "*.txt"		# add all files endswith ".txt" in the whole project!

snippets 字体很棒

字体很棒

FontAwesome CDN.snippets
https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css

snippets 布尔玛CDN

布尔玛CDN

Bulma.snippets
https://cdnjs.com/libraries/bulma

snippets Bootstrap CDN

Bootstrap CDN

Bootstrap CDN.snippets
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">


<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

snippets brew php libjpeg d8问题

问题是Homebrew的jpeg公式已经升级到v9,但现有的“瓶装”PHP公式仍然构建并与之前的版本v8相关联,该版本已不再存在于您的系统中。 (来源:https://stackoverflow.com/a/45695529)

brew_php_jpeg_update
brew reinstall --with-httpd24 --with-homebrew-curl --build-from-source php71

snippets 片段

片段

php-esc-url.snippets
<snippet>
	<content><![CDATA[
echo esc_url( home_url( '${1:url}' ) );
]]></content>
	<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
	<tabTrigger>eu</tabTrigger>
	<!-- Optional: Set a scope to limit where the snippet will trigger -->
	<!-- <scope>source.python</scope> -->
</snippet>
php-esc-html.snippets
<snippet>
	<content><![CDATA[
echo esc_html( \$${1:this} );
]]></content>
	<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
	<tabTrigger>eh</tabTrigger>
	<!-- Optional: Set a scope to limit where the snippet will trigger -->
	<!-- <scope>source.php</scope> -->
</snippet>
php-esc-html-e.snippets
<snippet>
	<content><![CDATA[
esc_html_e( '${1:this}', 'base' );
]]></content>
	<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
	<tabTrigger>ee</tabTrigger>
	<!-- Optional: Set a scope to limit where the snippet will trigger -->
	<!-- <scope>source.php</scope> -->
</snippet>
php-echo-print-r.snippets
<snippet>
	<content><![CDATA[
echo '<pre>';
print_r( \$${1:this} );
echo '</pre>';
]]></content>
	<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
	<tabTrigger>ep</tabTrigger>
	<description>echo pre with print_r</description>
	<!-- Optional: Set a scope to limit where the snippet will trigger -->
	<!-- <scope>source.python</scope> -->
</snippet>
php-acf-repeater.snippets
<snippet>
	<content><![CDATA[
if ( have_rows( '${1:row_name}' ) ) :
	?>
	<ul class="container">
		<?php
		while ( have_rows( '${1:row_name}' ) ) :
			the_row();
			// Get sub fields.
			\$name = get_sub_field( 'name' );
			?>
			<li></li>
			<?php
		endwhile;
		?>
	</ul>
	<?php
endif;
]]></content>
	<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
	<tabTrigger>ifw</tabTrigger>
	<!-- Optional: Set a scope to limit where the snippet will trigger -->
	<!-- <scope>source.html</scope> -->
</snippet>
php-acf-get-field.snippets
<snippet>
	<content><![CDATA[
\$${1:name} = get_field( '${1:name}' );
]]></content>
	<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
	<tabTrigger>gf</tabTrigger>
	<!-- Optional: Set a scope to limit where the snippet will trigger -->
	<!-- <scope>source.python</scope> -->
</snippet>
js-console-log.snippets
<snippet>
	<content><![CDATA[
console.log( ${1} );
]]></content>
	<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
	<tabTrigger>con</tabTrigger>
	<!-- Optional: Set a scope to limit where the snippet will trigger -->
	<scope>source.js</scope>
</snippet>
html-row.snippets
<snippet>
	<content><![CDATA[
<div class="row">
	<div class="medium-6 columns">

	</div>

	<div class="medium-6 columns">

	</div>
</div>
]]></content>
	<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
	<tabTrigger>row</tabTrigger>
	<!-- Optional: Set a scope to limit where the snippet will trigger -->
	<!-- <scope>source.python</scope> -->
</snippet>
css-rem-calc.snippets
<snippet>
	<content><![CDATA[
rem-calc(${1})
]]></content>
	<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
	<tabTrigger>rc</tabTrigger>
	<!-- Optional: Set a scope to limit where the snippet will trigger -->
	<!-- <scope>source.python</scope> -->
</snippet>
css-media-query.snippets
<snippet>
	<content><![CDATA[
@include mq(\$mq-${1:full}) {
	${2}
}
]]></content>
	<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
	<tabTrigger>mq</tabTrigger>
	<!-- Optional: Set a scope to limit where the snippet will trigger -->
	<!-- <scope>source.python</scope> -->
</snippet>
css-comment-partial.snippets
<snippet>
	<content><![CDATA[
//--------------------------------------------------------------
// ${1:Partial Description}
//--------------------------------------------------------------
]]></content>
	<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
	<tabTrigger>partialcomment</tabTrigger>
	<!-- Optional: Set a scope to limit where the snippet will trigger -->
	<scope>source.scss</scope>
</snippet>
css-comment-element.snippets
<snippet>
	<content><![CDATA[
//-----------------------------------------
// ${1:Element}
//-----------------------------------------
]]></content>
	<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
	<tabTrigger>elementcomment</tabTrigger>
	<!-- Optional: Set a scope to limit where the snippet will trigger -->
	<scope>source.scss</scope>
</snippet>
css-bracket.snippets
<snippet>
	<content><![CDATA[
${1:this} {
	$2
}
]]></content>
	<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
	<tabTrigger>bracket</tabTrigger>
	<!-- Optional: Set a scope to limit where the snippet will trigger -->
	<scope>source.scss</scope>
</snippet>