Skip to content

Instantly share code, notes, and snippets.

Toshiyuki Masui masui

Block or report user

Report or block masui

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@masui
masui / problem9.rb
Created May 25, 2015
a^2 + b^2 == c^2 かつ a+b+c=1000, a < b < c となる a, b, c を求める
View problem9.rb
(1..1000).each { |i|
(1..1000).each { |j|
k = 1000 - i - j
next if j <= i || k <= j
puts "#{i}, #{j}, #{k}" if i*i + j*j == k*k
}
}
@masui
masui / raspi_mouse.rb
Last active Aug 29, 2015
Raspberry PiのRubyでマウスホイール信号を取得する
View raspi_mouse.rb
File.open("/dev/input/event0","rb"){ |f|
while true do
s = f.read 16
(time, type, code, value) = s.unpack "qssi"
if type == 2 and code == 8 then
puts value
end
end
}
@masui
masui / raspi_mouse.c
Created Jan 22, 2015
Raspberry Piでマウスホイール信号を取得する
View raspi_mouse.c
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <linux/input.h> // struct input_event とか
main()
{
int mouse_fd = open("/dev/input/event0", O_RDONLY);
if (mouse_fd < 0) {
fprintf(stderr,"can't open mouse device\n");
@masui
masui / bing_search
Created Jan 10, 2015
Bingで画像検索
View bing_search
@masui
masui / Nexus6
Created Jan 9, 2015
Nexus6が発売されたら通知する
View Nexus6
system "wget -O /tmp/nexus6 https://play.google.com/store/devices/details/Nexus_6_64_GB_%E3%83%80%E3%83%BC%E3%82%AF%E3%83%96%E3%83%AB%E3%83%BC?id=nexus_6_blue_64gb"
res = system "grep '近日発売' /tmp/nexus6 > /dev/null"
unless res
system "echo 'Nexus6 is out.' | mail masui@pitecan.com"
system "echo 'Nexus6 is out.' | mail masui@masui.org"
end
@masui
masui / gist:6ec408cc5129a7919f58
Created Nov 29, 2014
Nexus6が発売されたら通知する
View gist:6ec408cc5129a7919f58
# -*- coding: utf-8 -*-
system "wget -O /tmp/nexus6 https://play.google.com/store/devices/details/Nexus_6_64_GB_%E3%83%80%E3%83%BC%E3%82%AF%E3%83%96%E3%83%AB%E3%83%BC?id=nexus_6_blue_64gb"
res = system "grep '近日発売' /tmp/nexus6 > /dev/null"
unless res
system "echo 'Nexus6 is out.' | mail masui@pitecan.com"
system "echo 'Nexus6 is out.' | mail masui@masui.org"
end
@masui
masui / defaultbrowser.rb
Created Nov 4, 2014
Macのデフォルトブラウザを知る
View defaultbrowser.rb
`defaults read com.apple.LaunchServices | grep -C3 'LSHandlerURLScheme = http;' | grep LSHandlerRoleAll | uniq` =~ /"(.*)"/
browser =
case $1
when /safari/i then "Safari"
when /chrome/i then "Chrome"
else "Firefox"
end
@masui
masui / gist:7a6713831d9ee9808b96
Created Nov 3, 2014
GyazoりつつWebページを推薦するスクリプト
View gist:7a6713831d9ee9808b96
# -*- coding: utf-8 -*-
require 'open-uri'
require 'nokogiri'
require 'httparty'
require 'net/http'
require 'uri'
#
# FirefoxをアクティブにしてURLを取得
View gist:d354c6269e3d7c41378f
function (ev, arg) {
var document = window.content.document;
var location = encodeURIComponent(document.location);
var title = encodeURIComponent(document.title);
var win = window.open('http://gyazz.masuilab.org/__write?name=osusume&title='+title+'&data=[['+location+']]');
win.close();
}
You can’t perform that action at this time.