Skip to content

Instantly share code, notes, and snippets.

View castaneai's full-sized avatar
🥳
Watching anime

castaneai castaneai

🥳
Watching anime
View GitHub Profile
// プログラムは WinMain から始まります
int APIENTRY WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
// ウィンドウモードにする
ChangeWindowMode(true);
// DXライブラリ開始処理
DxLib_Init();
// 裏画面に描画するように変更
@castaneai
castaneai / okatazuke.py
Created February 17, 2014 17:35
ファイルを拡張子に応じてディレクトリに分別して整理するスクリプト
# -*- coding: utf8 -*-
import os
import shutil
dir = os.getcwd()
rules = {
u"画像": [".jpg", ".png", ".gif"],
u"音楽": [".mp3", ".m4a"],
}
@castaneai
castaneai / po.c
Created April 13, 2014 10:10
逆ポーランド記法
#include <stdio.h>
int stack_head = 0;
int stack[100];
/**
* 四則演算に使う演算子
*/
typedef enum
{
package sim02;
public class River {
/**
* 横の長さと縦の長さを使って三平方の定理より斜辺の長さを求める
* @param width
* @param height
* @return
*/
@castaneai
castaneai / pyramid.cpp
Created April 16, 2014 15:21
5 => 1,2,3,4,5,4,3,2,1 のようなピラミッド型ループを作る
#include <iostream>
#include <functional>
using namespace std;
void pyramid(int max, function<void(int)> each)
{
for (int i = 1; i < max * 2; i++){
each(i - (i / max) * (i % max) * 2);
}
#include<stdio.h>
#include<math.h>
double qc(double a,double b,double c)/*qc means quadratic formula*/{
double result;
result=(-b+sqrt(pow(b,2)-4*a*c))/(2*a);
return result;
}
@castaneai
castaneai / recv_completely.cpp
Created May 1, 2014 06:50
[socket]指定バイト受信するまでブロックする関数
void reveive_completely(SOCKET sock, const int length, char* output) {
int received = 0;
while (received < length) recv(sock, output + received, length - received, 0);
}
@castaneai
castaneai / muse.md
Last active August 29, 2015 14:01
Muse仕様

Muse仕様

expressサーバー

- GET /musics : 曲一覧をJSONで取得 DB::search()の返り値をjsonに変換
- GET /audio/<id> : <id>の音声ファイルを出力
- GET /cover/<id> : <id>のカバー画像ファイルを出力
- POST /upload : 音声ファイルをアップロード
@castaneai
castaneai / easeljs_detect_collision.js
Last active August 31, 2020 10:27
detecting collisions between two DisplayObjects with EaselJS (CreateJS)
window.onload = function() {
// 初期設定
var canvas = document.createElement("canvas");
canvas.width = 500;
canvas.height = 250;
document.body.appendChild(canvas);
var stage = new createjs.Stage(canvas);
// 追従する箱
var box = new createjs.Shape();
@castaneai
castaneai / muse_distribution.md
Last active August 29, 2015 14:01
MuseのDistribution機能

MuseのDistribution機能

Museにログインしているユーザーはすべての曲を眺めることができる。

ここで、A,B,Cの3曲だけを誰かに渡したい場合

  • 選択モードでA,B,Cを選び、「一時URL発行」ボタンを押す
  • もらう側はURLにいくと3曲だけが並んだMuseが見える
  • ログインしている側は発行した一時URLを削除できる