Skip to content

Instantly share code, notes, and snippets.

@mia-0032
mia-0032 / image_resizer.php
Created March 20, 2013 16:16
画像の縦横比を保ったまま、必要に応じて黒帯をつけて表示するプログラム。
<?php
class ImageResizer {
public function resize($path, $width, $height) {
if (is_int($width) === FALSE || is_int($height) === FALSE) {
throw new Exception('$widthまたは$heightが不正');
}
if (is_string($path) && is_file($path)) {
$this->resizeImage($path, $width, $height);
@mia-0032
mia-0032 / Form1.cs
Created April 6, 2013 12:31
C#勉強会で作ったオセロゲーム。元々のソースは https://gist.github.com/7shi/5031182 です。少し自分でもいじってみました。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
@mia-0032
mia-0032 / HelloWorld.java
Created May 9, 2013 04:09
PlayFramework2.0でHelloWorld+UnitTest
package controllers;
import play.mvc.*;
import views.html.*;
public class HelloWorld extends Controller {
public static Result index() {
return ok("<b>Hello World</b>").as("text/html");
}
@mia-0032
mia-0032 / HelloworldFlex.mxml
Created May 9, 2013 04:59
Adobe FlexプロジェクトでHelloWorldとUnitTest
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<s:Button label="Hello World!!" click="clickButton()" />
<fx:Script>
import mx.controls.Alert;
public function clickButton():Boolean {
Alert.show("Hello World!!");
@mia-0032
mia-0032 / HelloworldAs.as
Created May 9, 2013 05:47
Adobe ASプロジェクトでHelloWorldとUnitTest
package
{
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
public class HelloworldAs extends Sprite
{
public function HelloworldAs()
@mia-0032
mia-0032 / Circle.as
Created May 10, 2013 11:02
「あの楽器」のAS版。途中まで作って飽きた。
package Innocencer.DisplayEffect
{
public class Circle extends EffectBase
{
public function Circle(x:Number, y:Number)
{
super(x, y);
}
public override function display():void
@mia-0032
mia-0032 / 01_aggregation.py
Last active August 24, 2018 13:35
Pythonで基本的な統計量を出力してみる
# -*- coding:utf-8 -*-
import numpy
from scipy import stats
n = 200
#正規分布にあてはまる乱数を生成
score_x = numpy.random.normal(171.77, 5.54, n)
score_y = numpy.random.normal(62.49, 7.89, n)
@mia-0032
mia-0032 / www_gj.R
Last active December 21, 2015 13:09
wコメントとGJコメントの相関ってあるのか調べるためのスクリプト
data = read.table('result.txt', header=TRUE, sep="\t", fileEncoding="utf8")
summary(data)
data$www = log(data$www + 1)
data$gj = log(data$gj + 1)
plot.new()
plot(data$www, data$gj, xlim=c(0, 12), ylim=c(0, 12), xlab="log(www_count)",ylab="log(gj_count)")
#線形回帰してみる
@mia-0032
mia-0032 / 02_graph.py
Created August 23, 2013 17:13
Pythonでヒストグラムと箱ひげ図を描く
# -*- coding:utf-8 -*-
import numpy
import pylab
#データの生成
n = 200
score_x = numpy.random.normal(171.77, 5.54, n)
score_y = numpy.random.normal(62.49, 7.89, n)
@mia-0032
mia-0032 / 03_linear.py
Last active February 29, 2016 06:28
Pythonとsklearnで単回帰分析
# -*- coding:utf-8 -*-
import numpy
import pylab
#import statsmodels.api
from sklearn import linear_model
n = 200
#データの生成