Skip to content

Instantly share code, notes, and snippets.

View kazoo04's full-sized avatar

Kazuya Gokita kazoo04

  • Garm Inc.
  • Tokyo
View GitHub Profile
# encoding: utf-8
require 'date'
@dic = {'朝' => 'first', '昼' => 'second', '夜' => 'third'}
def meshi(str)
today = Date.today
# encoding: utf-8
dic = {'朝' => 'first', '昼' => 'second', '夜' => 'third'}
# キーから対応する値を取れる
# 逆(値からキーを取る)はできない
puts dic['朝'] # first
puts dic['昼'] # second
puts dic['夜'] # third
# encoding: utf-8
require 'date'
require './timer.rb'
@last_update = nil
def tweet
d = DateTime.now
module.exports = function(grunt) {
grunt.initConfig({
});
};
@kazoo04
kazoo04 / capsule.rb
Created April 25, 2014 06:50
Capsule
# encoding: utf-8
WIDTH = 8
HEIGHT = 16
class Item
end
class Capsule < Item
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
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
background: #000;
}
.tape {
width: 400px;
#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;
@kazoo04
kazoo04 / pixels.cpp
Last active August 29, 2015 14:04
Replace all pixels
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;
@kazoo04
kazoo04 / all_pixels.c
Created August 3, 2014 14:33
all pixels (iplImage)
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];
}
}