Skip to content

Instantly share code, notes, and snippets.

View sassy's full-sized avatar
😀
happy hacking!

Satoshi Watanabe sassy

😀
happy hacking!
View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<title>Edge for Video</title>
<style>
#c1 {
display:none;
}
</style>
<script type="text/javascript">
@sassy
sassy / getUserMedia.html
Created October 6, 2014 15:31
PCのカメラの映像をvideoに流す
<html>
<head>
<script>
window.onload = function() {
if (navigator.webkitGetUserMedia) {
navigator.getUserMedia = navigator.webkitGetUserMedia;
} else if(navigator.mozGetUserMedia) {
navigator.getUserMedia = navigator.mozGetUserMedia;
}
function(ctx, aspectRatio, width, desiredWidth, height, desiredHeight, minX, minY, refX, refY) {
// aspect ratio - http://www.w3.org/TR/SVG/coords.html#PreserveAspectRatioAttribute
aspectRatio = svg.compressSpaces(aspectRatio);
aspectRatio = aspectRatio.replace(/^defer\s/,''); // ignore defer
var align = aspectRatio.split(' ')[0] || 'xMidYMid';
var meetOrSlice = aspectRatio.split(' ')[1] || 'meet';
// calculate scale
var scaleX = width / desiredWidth;
var scaleY = height / desiredHeight;
package main
import (
"fmt"
)
func main() {
for i := 0; i < 20; i++ {
switch {
case i % 15 == 0:
@sassy
sassy / hello_array_adapter.rb
Last active August 29, 2015 14:06
RubyMotion for AndroidでlistLiewを使ってみる ref: http://qiita.com/sassy_watson/items/53fb87d4814708c87760
class HelloArrayAdapter < Android::Widget::ArrayAdapter
def getView(position, convertView, parent)
textView = Android::Widget::TextView.new(context)
textView.text = self.getItem(position)
layout = Android::Widget::LinearLayout.new(context)
layout.addView(textView, Android::Widget::LinearLayout::LayoutParams.new(Android::View::ViewGroup::LayoutParams::MATCH_PARENT, Android::View::ViewGroup::LayoutParams::WRAP_CONTENT))
layout
end
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script>
var move = 200;
window.onload = function() {
var div = document.getElementById("viewport");
div.addEventListener("click", function(evt) {
var div = document.getElementById("wrapper");
@sassy
sassy / file0.txt
Created July 12, 2014 09:05
Canvasで画像の明るさを調整する(γ補正) ref: http://qiita.com/sassy_watson/items/0ef916c3d13e4b597e2c
出力 = (入力)^{\frac{1}{γ}}
@sassy
sassy / histogram.html
Created July 10, 2014 15:14
canvasとD3.jsで画像の輝度ヒストグラムをつくる ref: http://qiita.com/sassy_watson/items/c72139f9ea24503b462d
<!DOCTYPE html>
<html>
<head>
<script src="./jquery-2.1.1.min.js"></script>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script type="text/javascript">
function drawGraph(ys) {
//d3.js でグラフを描画する。
//グラフを描画するSVGを用意
@sassy
sassy / file0.txt
Created July 10, 2014 13:32
canvasで画像処理(ネガポジ変換/グレースケール変換) ref: http://qiita.com/sassy_watson/items/676af253d8425ce0f8fc
var data = context.getImageData(x, y, width, height);
@sassy
sassy / index.js
Created July 1, 2014 15:21
cordovaのjasmineテスト (プロジェクト作成時/jasmine2.0.0)
describe('app', function() {
describe('initialize', function() {
beforeEach(function() {
spyOn(app, 'onDeviceReady');
app.initialize();
helper.trigger(window.document, 'deviceready');
});
it('should bind deviceready', function() {
expect(app.onDeviceReady).toHaveBeenCalled();
});