Skip to content

Instantly share code, notes, and snippets.

@ChauThan
ChauThan / exe.sql
Last active March 22, 2024 14:51
[RecreateDatabase] #sqlserver #sql
EXEC sp_RecreateDatabase @DatabaseName = N'YourDatabase'; -- Thay 'YourDatabase' bằng tên cơ sở dữ liệu của bạn
@ChauThan
ChauThan / clean_code.md
Created October 17, 2023 03:07 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@ChauThan
ChauThan / Index.cs
Created June 19, 2018 07:12
[Humanized Date] #CSharp #DateTime #Format
internal static string HumanisedDate(this DateTime date)
{
string ordinal;
switch (date.Day)
{
case 1:
case 21:
case 31:
ordinal = "st";
@ChauThan
ChauThan / ContentReference
Created February 8, 2018 08:40 — forked from javafun/ContentReference
EPiServer - ContentReference Extensions
using System;
using System.Collections.Generic;
using EPiServer;
using EPiServer.Core;
using EPiServer.ServiceLocation;
using EPiServer7App.EPiServerCore.ContentTypes.Media;
using EPiServer7App.EPiServerCore.ContentTypes.Pages;
using EPiServer.Framework;
using System.IO;
using EPiServer7App.EPiServerCore.Model;
@ChauThan
ChauThan / regex-japanese.txt
Created January 3, 2018 06:33 — forked from terrancesnyder/regex-japanese.txt
Regex for Japanese
Regex for matching ALL Japanese common & uncommon Kanji (4e00 – 9fcf) ~ The Big Kahuna!
([一-龯])
Regex for matching Hirgana or Katakana
([ぁ-んァ-ン])
Regex for matching Non-Hirgana or Non-Katakana
([^ぁ-んァ-ン])
Regex for matching Hirgana or Katakana or basic punctuation (、。’)
@ChauThan
ChauThan / MetaEnumSelectionAttribute.cs
Last active November 30, 2017 03:32 — forked from jstemerdink/MetaEnumSelectionAttribute.cs
[MetaEnumSelectionAttribute] #episerver
using System;
using System.Web.Mvc;
using EPiServer.Shell.ObjectEditing;
using Mediachase.BusinessFoundation.Data.Meta.Management;
/// <summary>
/// The meta enum selection attribute.
/// </summary>
@ChauThan
ChauThan / Connection.cs
Created March 22, 2017 07:18 — forked from lancscoder/Connection.cs
Dapper Getting Started
public class ConnectionFactory {
public static DbConnection GetOpenConnection() {
var connection = new SqlConnection("MyConnectionString");
connection.Open();
return connection;
}
}
We couldn’t find that file to show.
@ChauThan
ChauThan / posts.js
Created June 3, 2016 12:00 — forked from glennblock/posts.js
Embeded gist syntax for Ghost. Place in ./core/server/api/posts.js.
//the code below will embed replace [gist id=x] tags with an embedded gist similar to the way the Wordpress Gist
//plugin works. I wrote this in order to import posts from Wordpress. See //GB: for the changes.
// **takes:** filter / pagination parameters
browse: function browse(options) {
options = options || {};
// **returns:** a promise for a page of posts in a json object
//return dataProvider.Post.findPage(options);
return dataProvider.Post.findPage(options).then(function (result) {
@ChauThan
ChauThan / gist:8698bc2756c075187848
Created December 2, 2015 11:18 — forked from thachpham92/gist:d57b18cf02e3550acdb5
Tất cả các tham số trong WP_Query
// Source: https://gist.github.com/luetkemj/2023628
// Xem hướng dẫn WP_Query toàn tập: http://goo.gl/kRpzTz
<?php
$args = array(
//////Author Parameters - Tham số lấy bài viết theo tác giả
//http://codex.wordpress.org/Class_Reference/WP_Query#Author_Parameters
'author' => '1,2,3,', //(int) - Các ID tác giả cần lấy bài viết (thêm dấu - vào để loại trừ tác giả, ví dụ: -14, -20)
'author_name' => 'luetkemj', //(string) - Lấy bài viết dựa theo tên nick name của tác giả
'author__in' => array( 2, 6 ), //(array) - Lấy bài dựa theo ID của tác giả