Skip to content

Instantly share code, notes, and snippets.

View champierre's full-sized avatar

Junya Ishihara champierre

View GitHub Profile
v 0.000000 -1.000000 -1.000000
v 0.000000 1.000000 0.000000
v 0.195090 -1.000000 -0.980785
v 0.382683 -1.000000 -0.923880
v 0.555570 -1.000000 -0.831470
v 0.707107 -1.000000 -0.707107
v 0.831470 -1.000000 -0.555570
v 0.923880 -1.000000 -0.382683
v 0.980785 -1.000000 -0.195090
v 1.000000 -1.000000 -0.000000
# cube.obj
#
g cube
v 0.0 0.0 0.0
v 0.0 0.0 1.0
v 0.0 1.0 0.0
v 0.0 1.0 1.0
v 1.0 0.0 0.0
@champierre
champierre / weather_api.rb
Last active May 18, 2017 07:54
Sample code to get weather info from https://developer.worldweatheronline.com/
require 'net/http'
require 'uri'
require 'json'
require 'byebug'
require 'csv'
API_KEY = "xxxx"
# query by lat and lng
# 35.443708,139.638026 is the lat and lng of yokohama city hall
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<h1>SpeedTest</h1>
<div id="speed"></div>
<script>
var imageAddr = "https://machique.st/assets/logo_s.png" + "?n=" + Math.random();
@champierre
champierre / color-log.gemspec
Last active January 8, 2016 15:38
color-log gem: Colorizes the output of the standard library debug logger. http://blog.champierre.com/1064
Gem::Specification.new do |spec|
spec.name = "color-log"
spec.version = "0.0.1"
spec.authors = ["Junya Ishihara"]
spec.email = ["webmaster@champierre.com"]
spec.summary = "Colorizes the output of the standard library debug logger."
spec.files = ["color-log.rb"]
spec.require_path = "."
end
@champierre
champierre / base_order_info_retriever_sample.user.js
Last active August 29, 2015 14:27
Sample Greasemonkey script that retrieves order info from BASE admin page
// ==UserScript==
// @name Base Order Info Retriever Sample
// @namespace http://tsukurusha.com/
// @version 1.0
// @description Sample Greasemonkey script that retrieves order info from BASE admin page
// @author Junya Ishihara
// @match http://*/*
// @grant GM_setValue
// @include https://admin.thebase.in/*
// @require http://code.jquery.com/jquery-2.1.4.min.js
require "socket"
require 'twitter'
# ログイン
client = Twitter::REST::Client.new do |config|
config.consumer_key = 'Application Consumer Key (API Key)'
config.consumer_secret = 'Application Consumer Secret (API Secret)'
config.access_token = 'Your Access Token'
config.access_token_secret = 'Your Access Token Secret'
end
require 'twitter'
# ログイン
client = Twitter::REST::Client.new do |config|
config.consumer_key = 'Application Consumer Key (API Key)'
config.consumer_secret = 'Application Consumer Secret (API Secret)'
config.access_token = 'Your Access Token'
config.access_token_secret = 'Your Access Token Secret'
end
# TCPSocket を使うため socket ライブラリを読み込みます
require "socket"
# localhost の TCP 番号 42001 番に接続します
socket = TCPSocket.open("localhost", 42001)
# 命令の内容
#command = "broadcast \"a\""
command = "sensor-update \"a\" 1"
@champierre
champierre / broadcast.rb
Last active August 29, 2015 14:08
send message to Scratch
# TCPSocket を使うため socket ライブラリを読み込みます
require "socket"
# localhost の TCP 番号 42001 番に接続します
socket = TCPSocket.open("localhost", 42001)
# 命令の内容
command = "broadcast \"a\""
# 命令の文字数(=バイト数)