Skip to content

Instantly share code, notes, and snippets.

View masazdream's full-sized avatar

Masahiro I masazdream

View GitHub Profile
@masazdream
masazdream / string2uchar.cpp
Created August 13, 2013 10:56
stringはそもそもchar配列ということを理解するプログラム。
string line2;
cout << "何か数字を入力してください> " << flush;
getline(cin, line2);
cout << line2 << endl;
const char* line_array = line2.c_str();
const int size = line2.size();
cout << "文字列配列の長さ: " << size << endl;
@masazdream
masazdream / Ec2Tools.java
Created August 13, 2013 15:40
AWSのEC2を起動、停止するプログラム
package jp.masaz.aws;
import java.util.ArrayList;
import java.util.List;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.regions.Region;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.ec2.AmazonEC2Client;
import com.amazonaws.services.ec2.model.InstanceState;
@masazdream
masazdream / GeocoderApp.java
Created August 14, 2013 12:23
google apiを使ったジオコーダーと逆ジオコーダー
public class GeocoderApp {
public static String invGeocode(double lat, double lng){
final Geocoder geocoder = new Geocoder();
BigDecimal latB = new BigDecimal(lat);
BigDecimal lngB = new BigDecimal(lng);
LatLng location = new LatLng(latB, lngB);
GeocoderRequest geocoderRequest = new GeocoderRequestBuilder().setLocation(location).setLanguage("ja").getGeocoderRequest();
GeocodeResponse geocoderResponse = geocoder.geocode(geocoderRequest);
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>JavaScriptの学習</title>
</head>
<body>
<h1>JavaScriptの学習</h1>
<p><input type="button" value="クリック!" id="myButton"></p>
void print2(var v) { print(v * 2); }
main() {
var vs = [1, 7, 3, 2, 0, 5, 0, 4];
print('--1--');
vs.forEach(print);
print('--2--');
vs.forEach(print2);
print('--3--');
vs.forEach( (a) => print(a*a) );
<html>
<head>
<meta charset="utf-8">
<title>A Minimalist App</title>
<link rel="stylesheet" href="helloworld.css">
</head>
<body>
<h1>A Minimalist App</h1>
<p>Hello world from Dart!</p>
@masazdream
masazdream / dft.cpp
Last active December 28, 2015 15:49
opencv dft sample
Mat padded;
int m = getOptimalDFTSize( I.rows ); ← I に元画像をimreadしてください
int n = getOptimalDFTSize( I.cols );
copyMakeBorder(I, padded, 0, m - I.rows, 0, n - I.cols, BORDER_CONSTANT, Scalar::all(0));
Mat planes[] = {Mat_<float>(padded), Mat::zeros(padded.size(), CV_32F)};
Mat complexI;
merge(planes, 2, complexI);
dft(complexI, complexI);
@masazdream
masazdream / image_load.cpp
Last active January 8, 2019 05:55
PPM画像のロードと保存
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
/* 定数宣言 */
#define MAX_IMAGESIZE 4000 /* 想定する縦・横の最大画素数 */
#define MAX_BRIGHTNESS 255 /* 想定する最大階調値 */
@masazdream
masazdream / labeling.cpp
Created January 26, 2014 10:04
画像の4近傍ラベリング、8近傍はsearch_4neighborsの探索範囲に4つ加えれば良い。
/* ラベル用大域変数 */
const int MAX_IMAGESIZE = 4000;
int label[MAX_IMAGESIZE][MAX_IMAGESIZE];
int labeling( int n, int red, int green, int blue );
/* ラベリングを行う関数 */
int search_4neighbors( int x, int y, int n );
/* 4近傍のラベルの最大値を返す関数 */
void modify_label( int num1, int num2, int n );
@masazdream
masazdream / Utils.cpp
Created February 15, 2014 09:00
cppでよく使う処理をまとめた。
/*
* Utils.cpp
*
* Created on: 2013/06/19
* Author: root
*/
#include "Utils.h"
using namespace std;