Skip to content

Instantly share code, notes, and snippets.

View KentaYamada's full-sized avatar
🏠
Working from home

yamaken KentaYamada

🏠
Working from home
View GitHub Profile
@KentaYamada
KentaYamada / Main.cs
Created May 9, 2016 13:11
State Pattern...??
using System;
namespace StatePattern
{
class Program
{
static void Main(string[] args)
{
IState state = new StateA(); //Start state
string target = "D"; //Target state
@KentaYamada
KentaYamada / RefVector.cpp
Created April 21, 2016 14:52
Vectorを参照渡しして使う
#include <iostream>
#include <string>
#include <vector>
using namespace std;
vector<unsigned int> runs;
static void InitRuns()
{
@KentaYamada
KentaYamada / filestatus.vim
Created April 16, 2016 14:10
Vimのステータスバーにファイル情報を表示する
" Vimの改行コード表示がちと変わっているので、
" 一般的な改行コードに変換してステータスバーに表示するようにカスタマイズ
" 改行コード対応表
" CRLF: dos
" CR: unix
" LF: mac
set statusline = 2 "ステータスバーの表示行数を設定
let dic_line = { 'dos': 'CRLF', 'unix': 'CR', 'mac': 'LF'}
let f = &fileformat " 改行コード取得
@KentaYamada
KentaYamada / install_packages.sh
Created March 28, 2016 14:01
パッケージインストール自動化スクリプト
#!/bin/bash
# インストールしたいパッケージを列挙
packages=("ibus-mozc" "sqlite3" "monodevelop")
for p in ${packages[@]}
do
#順番にインストール
sudo apt-get install $p
done
@KentaYamada
KentaYamada / pyodbc_sample1.py
Created December 30, 2015 12:41
Connect MSSQL(ODBC)
#-*- coding utf-8 -*-
import pyodbc
def test():
connectString = "DRIVER={SQL SERVER}; SERVER=(local)\SQLEXPRESS;DATABASE=;TrustedConnction=yes;"
sql = "select sysdb.name from sysdatabases sysdb"
#connect server
with pyodbc.connect(connectString) as conn:
cursor = conn.cursor()
@KentaYamada
KentaYamada / DecimalToBinaryAndHex.c
Last active November 1, 2015 12:58
10進数から2進数、16進数に変換して表示するプログラム
//-------------------------------------------------------------------
//10進数→2進数 & 16進数変換プログラム(C言語版)
//エミュレータで通信信号送る時に計算めんどくさいから作ってみた。
//ナンセンスな部分があるのはご愛嬌
//-------------------------------------------------------------------
#include <stdio.h>
void to_binary(int decimal)
{
int buf[32] = {0};
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.Entity;
using System.Data.SqlClient;
using System.Linq;
namespace Koubou.SQLServer.EF
{
@KentaYamada
KentaYamada / SendErrorLog.cs
Created February 15, 2015 12:38
エラーログを送信する
using System;
using System.Net;
using System.Net.Mail;
using System.Diagnostics;
using System.Text;
public static class SendErrorLog
{
public static void Send(Exception ex)
{
@KentaYamada
KentaYamada / ListToDataTable.cs
Created December 2, 2014 04:55
List<T>からDataTable型へ変換する
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Reflection;
namespace ListToDataTable
{
class Program
{
@KentaYamada
KentaYamada / sample.js
Created November 8, 2014 02:54
JavaScriptのXMLHttpRequestを試してみる
/*
* ブラウザ判別
*/
function getBrowserKind() {
return navigator.userAgent.toLowerCase();
}
/*
* 通信