This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for(y=0; y<height; y++) { | |
for(x=0; x<width; x++) { | |
int index = img->widthStep*y+(x*3); | |
int b = img->imageData[a+0]; | |
int g = img->imageData[a+1]; | |
int r = img>imageData[a+2]; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cv::Mat src = cv::imread("example.jpg"); | |
for(int y = 0; y < src.rows; ++y){ | |
for(int x = 0; x < src.cols; ++x){ | |
int index = y * src.step + x * src.elemSize(); | |
int r = src.data[index + 2]; | |
int g = src.data[index + 1]; | |
int b = src.data[index + 0]; | |
if(r == 255 && g == 255 && b == 255) { | |
src.data[index + 2] = 0; | |
src.data[index + 1] = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <math.h> | |
int main(int argc, char **argv) { | |
int n = 1111111; | |
printf("%d", n); | |
int b = 10; | |
int buffer = n % 10; n /= 10; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<style> | |
body { | |
background: #000; | |
} | |
.tape { | |
width: 400px; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def valid_image?(filename) | |
File.open(filename, "rb") do |file| | |
begin | |
header = file.read(8) | |
file.seek(-12, IO::SEEK_END) | |
footer = file.read(12) | |
rescue | |
return false | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
WIDTH = 8 | |
HEIGHT = 16 | |
class Item | |
end | |
class Capsule < Item |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
WIDTH = 8 | |
HEIGHT = 16 | |
$field = Array.new(WIDTH).map{Array.new(HEIGHT, :none)} | |
def cell(x, y, offset_x = 0, offset_y = 0) | |
_x = x + offset_x | |
_y = y + offset_y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(grunt) { | |
grunt.initConfig({ | |
}); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
require 'date' | |
require './timer.rb' | |
@last_update = nil | |
def tweet | |
d = DateTime.now |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
dic = {'朝' => 'first', '昼' => 'second', '夜' => 'third'} | |
# キーから対応する値を取れる | |
# 逆(値からキーを取る)はできない | |
puts dic['朝'] # first | |
puts dic['昼'] # second | |
puts dic['夜'] # third |