Skip to content

Instantly share code, notes, and snippets.

View tetsunosuke's full-sized avatar

ITO Tetsunosuke tetsunosuke

View GitHub Profile
function padZero(v) {
return v < 10 ? "0" + new String(v) : new String(v);
}
function getBars(str) {
var result = 0;
var bars = {0: 6, 1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 4, 8: 7, 9: 6};
for (var i=0; i < str.length; i++) {
result += bars[str[i]];
}
return result;
<?php
error_reporting(E_ALL);
while($line=fgets(STDIN))
{
echo trim(solve($line)) . "\n";
}
function solve($str) {
for ($i = 0; $i < 26; $i++) {
@tetsunosuke
tetsunosuke / gist:0338381f0501f0adf9cb
Created March 24, 2015 11:53
django で model を書いてE-R図自動生成
from django.db import models
# Create your models here.
class Order(models.Model):
#id = models.CharField(max_length=10)
num = models.CharField(max_length=10)
purchase_method_code = models.CharField(max_length=10)
input_staff_id = models.CharField(max_length=10)
member_id = models.CharField(max_length=10)
store_id = models.CharField(max_length=10)
@tetsunosuke
tetsunosuke / gist:85d887abf000e2482b3c
Created April 10, 2015 03:38
アジトオブスクラップ横浜の問題を解く
<?php
// 利用する文字
$nums = array(
2, 3, 5, 6, 7, 8, 9
);
$perm = pc_permute($nums);
foreach($perm as $clue) {
list($spade, $heart, $diamond, $club, $x, $y, $z) = $clue;
if (solve($spade, $heart, $diamond, $club, $x, $y, $z) !== false) {
@tetsunosuke
tetsunosuke / google_apps_checkboxes.gs
Created November 10, 2012 03:26
GoogleAppsScriptでチェックボックス の改造
// global にしておく
var checkBoxArray = ['幼少期(0~6歳頃)',
'学童期(6~12歳頃)',
'青年期(12~25歳頃)',
'成人期(25~40歳頃)',
'中年期(40~65歳頃)',
'老年期(65歳~)'];
function doGet() {
@tetsunosuke
tetsunosuke / checkbox_with_gui.js
Created November 13, 2012 03:41
CheckBox with GUI
// Script-as-app template.
function doGet() {
// GUIビルダーで初期表示
var app = UiApp.createApplication();
var myGui = app.loadComponent("MyGui");
app.add(myGui);
// 初期値設定
UserProperties.setProperty("red" ,false);
UserProperties.setProperty("blue" ,false);
@tetsunosuke
tetsunosuke / gmail2pdf.js
Created November 15, 2012 06:08
gmail2pdf
/**
* Retrieves all inbox threads and logs the respective subject lines.
* For more information on using the GMail API, see
* https://developers.google.com/apps-script/class_gmailapp
*/
function processInbox() {
// get all threads in inbox
var threads = GmailApp.getInboxThreads();
for (var i = 0; i < threads.length; i++) {
// get all messages in a given thread
@tetsunosuke
tetsunosuke / gmailsmap2inbox.gs
Created December 4, 2012 04:11
gmailsmap2inbox
/**
* Retrieves all inbox threads and logs the respective subject lines.
* For more information on using the GMail API, see
* https://developers.google.com/apps-script/class_gmailapp
*/
function processInbox() {
// get all threads in inbox
threads = GmailApp.getSpamThreads();
for (var i = 0; i < threads.length; i++) {
// get all messages in a given thread
@tetsunosuke
tetsunosuke / othello.html
Created October 16, 2015 10:35 — forked from wgkoro/othello.html
おせろゲーム ベースHTML (とサンプルスクリプト)
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title>おせろ</title>
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<style>
@tetsunosuke
tetsunosuke / Coverage.php
Created July 9, 2013 05:03
カバレッジを行ごとにファイルに記録する
<?php
function my_xdebug_shutdown() {
$result = xdebug_get_code_coverage();
foreach($result as $file => $covers) {
$lines = file($file);
if (!isCoverageTargetFile($file)) {
continue;
}