Skip to content

Instantly share code, notes, and snippets.

@typosone
typosone / breakout.js
Last active August 14, 2017 01:47
2017 1-2期 の Programming Trainingのやつ
window.addEventListener('DOMContentLoaded', function () {
console.log('breakout.js loaded!');
// 実装
class Paddle {
constructor() {
this.x = 240;
this.y = 600;
}
draw(context) {
import turtle
def triangle(pen, size):
"""penを使用して一辺の長さsizeの正三角形を描きます"""
for a in range(3):
pen.forward(size)
pen.left(120)
def square(pen, size):
@typosone
typosone / breakout.py
Created July 29, 2015 01:51
Breakout
from tkinter import *
import random
import time
class Ball:
def __init__(self, canvas, paddle, speed, color):
self.canvas = canvas
self.paddle = paddle
self.speed = speed
self.id = canvas.create_oval(10, 10, 25, 25, fill=color)
@typosone
typosone / test_student_code.py
Last active August 29, 2015 14:25
学籍番号チェック関数のテストケース
import unittest
import student_code
class StudentCodeTest(unittest.TestCase):
exists_student_codes = [
's15001', 's15002', 's15003', 's15004', 's15005',
's15006', 's15007', 's15008', 's15009', 's15010',
's15011', 's15012', 's15013', 's15014',
'n15001', 'n15002', 'n15003', 'n15004', 'n15005',
@typosone
typosone / test_fizzbuzz.py
Last active August 29, 2015 14:25
fizzbuzz の簡単なユニットテストする
import sys
from io import StringIO
import unittest
import fizzbuzz
pattern10 = """1\n2\nfizz\n4\nbuzz\nfizz\n7\n8\nfizz\nbuzz\n"""
pattern100 = """1\n2\nfizz\n4\nbuzz\nfizz\n7\n8\nfizz\nbuzz
11\nfizz\n13\n14\nfizz buzz\n16\n17\nfizz\n19\nbuzz
fizz\n22\n23\nfizz\nbuzz\n26\nfizz\n28\n29\nfizz buzz
31\n32\nfizz\n34\nbuzz\nfizz\n37\n38\nfizz\nbuzz
41\nfizz\n43\n44\nfizz buzz\n46\n47\nfizz\n49\nbuzz
@typosone
typosone / MainActivity.java
Last active August 29, 2015 14:11
Android の Service のさんぷる
package jp.ac.it_college.std.nakasone.servicetest;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.view.View;
package jp.ac.it_college.std.nakasone.actionbartab;
import android.app.ActionBar;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@typosone
typosone / pass_gen.py
Created July 29, 2014 17:47
Python3 でランダム文字列作るやつ。
#!/usr/bin/env python3
import sys
import random
argv = sys.argv
argc = len(argv)
if argc not in {2, 3}:
print("Usage: pass_gen digis [mode(1:number,2:lower,4:upper,8:specials]")
@typosone
typosone / tmux.conf
Created July 13, 2014 16:06
いつものドットファイル (バックアップ
set-option -g prefix C-j
setw -g utf8 on
set -g status-utf8 on
set -g mouse-select-pane on
setw -g mode-mouse on
set -g terminal-overrides 'xterm*:smcup@:rmcup@'
set -g base-index 1
@typosone
typosone / odd_even.py
Created July 4, 2014 06:32
てきとーに奇偶判定
#!/usr/bin/env python3
def isOdd(i):
return False if i & 0x1 == 0 else True
def isEven(i):
return not isOdd(i)
if __name__ == '__main__':
for x in range(100):