Skip to content

Instantly share code, notes, and snippets.

@ChauThan
ChauThan / 0_reuse_code.js
Created November 11, 2013 04:59
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ChauThan
ChauThan / Last_Execution_Of_Store_Procedured.sql
Created November 11, 2013 07:36
Get last execution of store procedured
SELECT CASE PS.database_id
WHEN 32767
THEN 'Resource DB'
ELSE DB_NAME(PS.database_id)
END AS [DB Name]
,OBJECT_NAME(PS.object_id, PS.database_id) AS [SP Name]
,PS.last_execution_time AS [Last Executed]
,PS.execution_count AS [# runs]
FROM sys.dm_exec_procedure_stats PS
ORDER BY DB_NAME(PS.database_id)
@ChauThan
ChauThan / Find_Column_From_All_Tables.sql
Created November 15, 2013 02:22
How many tables in database AdventureWorks have column name like ‘EmployeeID’?
SELECT t.NAME AS table_name
,SCHEMA_NAME(schema_id) AS schema_name
,c.NAME AS column_name
FROM sys.tables AS t
INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
WHERE c.NAME LIKE '%EmployeeID%'
ORDER BY schema_name
,table_name;
@ChauThan
ChauThan / Check_Duplicate_Before_Insert_Multiple_Record.sql
Created November 15, 2013 10:31
How to check record exists before INSERT multiple records
INSERT INTO TargetTable (
id
,email
,NAME
)
SELECT id
,email
,NAME
FROM SourceTable AS S
WHERE NOT EXISTS (
@ChauThan
ChauThan / Update_twice_inner_join.sql
Created November 18, 2013 12:10
Khi sử dụng update ... from nếu tham chiếu 2 lần cùng một bản thì có thể sử dụng như sau
-- sử dụng bản gốc
UPDATE TargetTable
SET
Name = 'XXX'
FROM
TargetTable parentTable
INNER JOIN TargetTable
ON
parentTable.id = TargetTable.parent_id
WHERE
@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ả
@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) {
We couldn’t find that file to show.
@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;
}
}
@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>