Skip to content

Instantly share code, notes, and snippets.

@wgkoro
wgkoro / 0_reuse_code.js
Created February 18, 2016 03:53
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@wgkoro
wgkoro / web_checker.py
Last active December 19, 2015 23:39
超手抜き版Webページチェッカー HTTPでアクセスして、ステータスコードが4xx以上であればメール送信
#!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
Author : wg_koro
Update : 2013/7/10
Web page checker
"""
import urllib
@wgkoro
wgkoro / arduino.c
Last active December 11, 2015 08:58
Arduino (C)
#include "string.h"
// the setup routine runs once when you press reset:
void setup() {
Serial.begin(115200); // 速度
}
#define _Read_MAX_CHAR_ 50
// the loop routine runs over and over again forever:
void loop() {
@wgkoro
wgkoro / othello.html
Created October 16, 2015 08:33
おせろゲーム ベース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>
@wgkoro
wgkoro / jsutil.js
Created October 25, 2012 01:50
util of javascript
// Cookieに書き込む
function writeCookie(name, val, second){
var term = second * 1000;
var now = new Date();
var limit = new Date();
limit.setTime(limit.getTime() + term);
document.cookie = name + "=" + escape(val) + "; path=/; expires=" + limit.toUTCString();
}
function insertAfter(target, newElem){
@wgkoro
wgkoro / spscroll.js
Created October 24, 2012 11:43
Make scroll button at bottom of the page.
/*
Author : wg_koro
Version : 1.0
Update : 2012/10/24
License : MIT
- How to use -
Set this script in header.That's all! :)
(Example) <script type='text/javascript' src='xxxx/spscroll.js' charset='utf-8'></script>.
*/
@wgkoro
wgkoro / UrlParam.php
Created October 10, 2012 16:40
URLのパラメーター文字列を分解・比較するためのクラス
<?php
/**
Author : wg_koro
LastUpdate : 2012/10/11
License : MIT
URLのパラメーター文字列を分解・比較するためのクラス
使い方:
$p = new UrlParam();
@wgkoro
wgkoro / WiFiSwitcher.js
Created July 7, 2012 11:30
on{X} WiFi Toggle
// Initializing variables ==================================
// WiFi, BlueToothをONにする場所をセット。
// http://www.geocoding.jp/ を使うと緯度経度が分かります。
var location = [
{ name : "tokyo_tower", latitude : "35.65861", longitude : "139.745447" },
{ name : "ueno_station", latitude : "35.713768", longitude : "139.777254" }
];
var radius = 1000; // 目標地点を中心とした半径距離。この円を境目にスイッチ稼働。単位:メートル
var turn_on_bluetooth = false; // BluetoothもONにするならtrueに。
@wgkoro
wgkoro / file_write_in_try-catch.php
Last active August 29, 2015 14:25
try{ }catch の中でファイル書き込みを実行し、例外なげたらどうなるんだっけ?
<?php
// 結果:例外なげてもファイルに書き込まれる
try {
$fp = fopen('./fugafuga.log', 'a');
fwrite($fp, '123');
fclose($fp);
throw new Exception('e');
}
catch(Exception $e) {
@wgkoro
wgkoro / 0017.py
Last active August 29, 2015 14:17
AOJ-0017 Caesar Cipher
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import sys, string
alphabet = 'abcdefghijklmnopqrstuvwxyza'
table = string.maketrans(alphabet[:-1], alphabet[1:])
for s in sys.stdin:
while not('the' in s or 'this' in s or 'that' in s):
s = s.translate(table)