Skip to content

Instantly share code, notes, and snippets.

View tetsunosuke's full-sized avatar

ITO Tetsunosuke tetsunosuke

View GitHub Profile
<p>test</p>
@tetsunosuke
tetsunosuke / gist:0aeac1511a19010ff8fdec8a8a4c1d17
Created March 1, 2017 02:56
特定クラスで囲われたリンクに対してクリックイベントの付与
var clsName = "bnr_nenga";
var div = document.getElementsByClassName(clsName);
var a = div[0].getElementsByTagName("a")
var url = a[0].href;
// parse
var params = url.split("?");
// さらに & でわける...
@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 / 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 / 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)
<?php
error_reporting(E_ALL);
while($line=fgets(STDIN))
{
echo trim(solve($line)) . "\n";
}
function solve($str) {
for ($i = 0; $i < 26; $i++) {
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;
@tetsunosuke
tetsunosuke / gist:6710596
Created September 26, 2013 06:41
文字列を指定長で収まるようにするやつ
function Util_() {
/**
* mb_strwidth
* @param String
* @return int
* @see http://php.net/manual/ja/function.mb-strwidth.php
*/
this.mb_strwidth = function(str){
var i=0,l=str.length,c='',length=0;
for(;i<l;i++){
@tetsunosuke
tetsunosuke / ga.gs
Created September 10, 2013 03:09
GoogleAnalyticsAPIからデータを取るサンプルです
function GoogleAnalytics_() {
this.apiBase = "https://www.googleapis.com/analytics/v3/data/ga";
this.tokenUrl = "https://accounts.google.com/o/oauth2/token";
/**
* 認証用のヘッダーを作る
*/
this.buildAuthorizationHeader = function(token) {
headers = {
"Authorization" : "Bearer" + " " + token
@tetsunosuke
tetsunosuke / spreadsheet2xml.js
Last active December 19, 2015 15:08
スプレッドシートからXMLを作成する習作。
/**
* スプレッドシート内のデータからXMLデータを生成します
* 1行目にXMLのタグ名を入れると、それに応じてデータをXML化します
* XMLオブジェクトを使うことで、& -> &amp; などの処理をAppsScript側に任せています
*
* 例)
*
* id | name | no
* 1 | miura | 18
* 2 | blanco | 42