This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf8 -*- | |
import math | |
''' | |
ベクトルの内積を計算する | |
''' | |
def inner(vector1, vector2): | |
return sum([component1 * component2 for component1, component2 in zip(vector1, vector2)]) | |
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript: (function() { | |
if (!location.href.match(/^http:\/\/www\.kasi-time\.com\/item-([0-9]+)\.html/)) { | |
return false; | |
} | |
if (typeof jQuery == 'undefined') { | |
var d = document; | |
var e = d.createElement('script'); | |
e.type = 'text/javascript'; | |
e.onload = bml; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ostream> | |
struct Point | |
{ | |
public: | |
int x; | |
int y; | |
Point operator+(const Point&); | |
Point operator-(const Point&); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <iomanip> | |
#include <stdlib.h> | |
#include <time.h> | |
using namespace std; | |
string StateChars[] = {"・", "●", "○"}; | |
enum State |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Chat { | |
public string Name { get; set; } | |
public string Message { get; set; } | |
} | |
var server = new JsonOnline.Server(); | |
server.OnAccept += (client) => { | |
client.On<Chat>((_, chat) => { | |
client.Broadcast(chat); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
コールバック関数を持つサーバーを作れるサンプル | |
*/ | |
#pragma comment(lib, "ws2_32.lib") | |
#include <WinSock2.h> | |
#include <list> | |
typedef void (*ONRECV)(const SOCKET socket, const char* data, const int data_length); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma comment(lib, "ws2_32.lib") | |
/* | |
Windows.hをインクルードする場合は | |
#define WIN32_LEAN_AND_MEAN | |
を入れることで、Windows.hとWinsock2.hの定義衝突を回避できる | |
*/ | |
#include <Winsock2.h> | |
/* | |
返り値のconst char*はどこに確保されているのか、それは |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
5秒カウントダウンして終了するだけの簡単なスレッドのサンプル | |
*/ | |
#include <iostream> | |
#include <Windows.h> | |
// 引数でスレッドの終了を伝えるためのイベントハンドルを受け取る | |
DWORD WINAPI func(LPVOID eventContext) | |
{ | |
// 5秒カウントダウンする |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
使い方:SimpleThreadのコンストラクタにvoidを返し引数なしの関数を渡すだけ | |
void func() { | |
printf("Hello."); | |
} | |
void main() { | |
SimpleThread t(func); | |
t.Start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading.Tasks; | |
using System.Windows.Forms; | |
using System.Net; | |
namespace WindowsFormsApplication1 | |
{ | |
public partial class Form1 : Form | |
{ | |
private Client client; |
OlderNewer