Skip to content

Instantly share code, notes, and snippets.

@ichiroku11
ichiroku11 / app.ts
Last active August 29, 2015 13:55
TypeScript でライフゲーム
/// <reference path="gameoflife.ts" />
document.addEventListener("DOMContentLoaded", () => {
console.log(document.getElementById("content").innerHTML);
var width = 40;
var height = 30;
var defaults: { x: number; y: number }[] = [];
for (var x = 0; x < width; x++) {
for (var y = 0; y < height; y++) {
@ichiroku11
ichiroku11 / Program.cs
Last active August 29, 2015 14:02
Entity Frameworkでパラメータを渡してSQLを実行する
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dapper;
@ichiroku11
ichiroku11 / Program.cs
Created May 17, 2012 23:38
Hello gist
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApp {
class Program {
static void Main( string[] args ) {
Console.WriteLine( "Hello gist!!" );
}
@ichiroku11
ichiroku11 / Program.cs
Created May 23, 2012 03:06
System.Diagnostics.EventLogのサンプル
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace ConsoleApp {
static class Program {
static void Main( string[] args ) {
var source = "ConsoleApp"; // イベントソース名
@ichiroku11
ichiroku11 / Program.cs
Created May 23, 2012 03:04
System.Net.Mail.SmtpClientのサンプル
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Mail;
namespace ConsoleApp {
static class Program {
static void Main( string[] args ) {
@ichiroku11
ichiroku11 / gist:2848188
Created June 1, 2012 02:31
テーブル名、カラム名、データ型を表示するクエリ
select
sys.tables.name,
sys.columns.name,
sys.types.name
from sys.tables
inner join sys.columns
on sys.tables.object_id = sys.columns.object_id
inner join sys.types
on sys.columns.user_type_id = sys.types.user_type_id
order by
@ichiroku11
ichiroku11 / gist:2886211
Created June 7, 2012 02:37
テーブル名、カラム名からデフォルト制約名を取得するクエリ
declare @table sysname = 'table_name';
declare @column sysname = 'column_name';
select
sys.default_constraints.name, *
from sys.tables
inner join sys.columns
on sys.tables.object_id = sys.columns.object_id
inner join sys.default_constraints
on sys.tables.object_id = sys.default_constraints.parent_object_id and
@ichiroku11
ichiroku11 / gist:2892705
Created June 8, 2012 00:45
カーソルの使い方
-- cursorを宣言
declare cur cursor
for
select ...
-- cursorを開く
open cur;
-- 1行ごとにデータを取り出す
fetch next from cur into @v1, @v2, ...;
@ichiroku11
ichiroku11 / gist:2964883
Created June 21, 2012 09:44
主キー制約、ユニーク制約、外部キー制約の一覧を取得するクエリ
with cte_columns as(
select
sys.tables.object_id,
sys.columns.column_id,
sys.tables.name as table_name,
sys.columns.name as column_name
from sys.tables
inner join sys.columns
on sys.tables.object_id = sys.columns.object_id
where
@ichiroku11
ichiroku11 / gist:2987578
Created June 25, 2012 09:14
全テーブルのレコード数を取得するクエリ
-- 結果を格納するテーブル変数
declare @result table(
Name sysname not null,
Rows int not null
);
-- テーブル名を取得するカーソル
declare cur cursor
for
select