Skip to content

Instantly share code, notes, and snippets.

View shengLin-alex's full-sized avatar

Sheng-Wei Lin shengLin-alex

View GitHub Profile
@shengLin-alex
shengLin-alex / FooServiceTests.cs
Last active July 27, 2022 05:08
Unit test with AutoMapper
using AutoMapper;
using FluentAssertions;
using NSubstitute;
using NUnit.Framework;
namespace AutoMapperUnitTest;
public class BarEntity
{
public string Name { get; set; }
@shengLin-alex
shengLin-alex / traefik-rbac.yaml
Last active March 5, 2020 15:05
traefik k8s ingress controller
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: traefik-ingress-controller
rules:
- apiGroups:
- ""
resources:
- pods
@shengLin-alex
shengLin-alex / helper_node_composer.sh
Last active April 8, 2020 04:39
Deploy Laravel to EC2
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash \
&& . ~/.nvm/nvm.sh \
&& nvm install node \
&& php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
&& php -r "if (hash_file('sha384', 'composer-setup.php') === 'e0012edf3e80b6978849f5eff0d4b4e4c79ff1609dd1e613307e16318854d24ae64f26d17af3ef0bf7cfb710ca74755a') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" \
&& php composer-setup.php \
&& php -r "unlink('composer-setup.php');"
@shengLin-alex
shengLin-alex / .env
Created February 20, 2020 04:24
MoE dev .env
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:erv0M3mji8JKRZxT744WK85IgkRaL2Yp0dvJcgtKJe8=
APP_DEBUG=true
APP_URL=http://localhost/moe
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=mysql
@shengLin-alex
shengLin-alex / main.rs
Created October 10, 2018 08:30
A simple exercise, showing what different between filter reference and filter value.
#[derive(Debug, PartialEq)]
struct Shoe {
size: u32,
style: String
}
fn shoes_in_my_size(shoes: Vec<Shoe>, shoe_size: u32) -> Vec<Shoe> {
// shoes.iter() // 錯誤 iter() 無法獲取 vec 元素所有權, 只能取得 ref, 不符合回傳值的型態
// .filter(|s| s.size == shoe_size)
// .collect()