Skip to content

Instantly share code, notes, and snippets.

View cashwu's full-sized avatar
🌴
On vacation

Cash Wu cashwu

🌴
On vacation
View GitHub Profile
@cashwu
cashwu / iterm2-solarized.md
Created November 5, 2017 16:18 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font + [Powerlevel9k] - (macOS)

Default

Default

Powerlevel9k

Powerlevel9k

@cashwu
cashwu / DateTimeExtensions.cs
Created November 20, 2018 07:35 — forked from jasongaylord/DateTimeExtensions.cs
A DateTime extension to show a friendly date based on the value passed in and DateTime.Now
public static class DateTimeExtensions
{
public static string ToFriendlyDate(this DateTime date)
{
// Calculate the elapsed time
TimeSpan s = DateTime.UtcNow.Subtract(date);
// Get total number of days elapsed.
int dayDiff = (int)s.TotalDays;
@cashwu
cashwu / embedded-file-viewer.md
Created December 10, 2019 12:11 — forked from tzmartin/embedded-file-viewer.md
Embedded File Viewer: Google Drive, OneDrive

Office Web Apps Viewer

('.ppt' '.pptx' '.doc', '.docx', '.xls', '.xlsx')

http://view.officeapps.live.com/op/view.aspx?src=[OFFICE_FILE_URL]

<iframe src='https://view.officeapps.live.com/op/embed.aspx?src=[OFFICE_FILE_URL]' width='px' height='px' frameborder='0'>
</iframe>

OneDrive Embed Links

@cashwu
cashwu / AppDbContext.cs
Last active January 31, 2020 05:26
EF Core for test
//dotnet ef migrations add init
//dotnet ef database update
public class AppDbContext : DbContext
{
public AppDbContext(DbContextOptions options)
: base(options)
{
@cashwu
cashwu / scalpel.ruleset
Created April 23, 2020 06:22
stypecop rule
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="StyleCopRules" Description="StyleCop Analyzers" ToolsVersion="15.0">
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
<Rule Id="SA0001" Action="None"/>
<Rule Id="SA1003" Action="None"/>
<Rule Id="SA1101" Action="None"/>
<Rule Id="SA1116" Action="None"/>
<Rule Id="SA1200" Action="None"/>
<Rule Id="SA1309" Action="None"/>
<Rule Id="SA1310" Action="None"/>
using System;
using System.Runtime.Caching;
using AspectInjector.Broker;
namespace testAspectInjector
{
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
[Injection(typeof(CacheAspect), Inherited = true)]
public abstract class AspectCacheAttribute : Attribute
{
const fetch = require('node-fetch')
const fs = require('fs-extra')
const { execSync } = require('child_process')
const main = async () => {
const query = `nasa,cycling,surfing,underwater,swimming`
const size = `1`
const order = `latest`
const orientation=`landscape`
const photoName = 'photo.png'
@cashwu
cashwu / dateonlybetween.cs
Created May 22, 2021 06:06 — forked from mattjohnsonpint/dateonlybetween.cs
DateOnly Between methods
public static int DaysBetween(DateOnly startDate, DateOnly endDate)
{
return endDate.DayNumber - startDate.DayNumber;
}
public static (int Months, int Days) MonthsAndDaysBetween(DateOnly startDate, DateOnly endDate)
{
int months = (endDate.Year - startDate.Year) * 12 + endDate.Month - startDate.Month;
DateOnly testDate = startDate.AddMonths(months);
@cashwu
cashwu / LocalizeTagHelper.cs
Created November 3, 2022 06:47 — forked from nadjibus/LocalizeTagHelper.cs
An ASP.NET Core Tag Helper that makes localization pretty straightforward
using Microsoft.AspNetCore.Razor.TagHelpers;
[HtmlTargetElement(LocalizeTagName)] // This is for <localize>Content here</localize> syntax
[HtmlTargetElement(Attributes = LocalizeTagName)] // This is for <p localize>Content here</p> syntax, which I personally prefer
public class LocalizeTagHelper : TagHelper
{
private const string LocalizeTagName = "localize";
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
@cashwu
cashwu / semantic-commit-messages.md
Created November 25, 2022 03:48 — forked from joshbuchea/semantic-commit-messages.md
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example