Skip to content

Instantly share code, notes, and snippets.

View champierre's full-sized avatar

Junya Ishihara champierre

View GitHub Profile
@champierre
champierre / pry_message.rb
Last active August 29, 2015 14:05
pry message from scratch
# TCPSocket を使うため socket ライブラリを読み込みます
require "socket"
# localhost の TCP 番号 42001 番に接続します
socket = TCPSocket.open("localhost", 42001)
loop do
# 十分な長さのメッセージを読み取る
message = socket.recv(100)
@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\""
# 命令の文字数(=バイト数)
# TCPSocket を使うため socket ライブラリを読み込みます
require "socket"
# localhost の TCP 番号 42001 番に接続します
socket = TCPSocket.open("localhost", 42001)
# 命令の内容
#command = "broadcast \"a\""
command = "sensor-update \"a\" 1"
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 "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
@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
@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
<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 / 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
# 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