Skip to content

Instantly share code, notes, and snippets.

View HituziANDO's full-sized avatar

Hituzi Ando HituziANDO

View GitHub Profile
@HituziANDO
HituziANDO / consoleInput.java
Last active October 9, 2015 06:07
Java_ConsoleInput
private static String consoleInput (String prompt) throws IOException {
if (prompt != null) {
System.out.print(prompt);
}
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
return br.readLine();
}
@HituziANDO
HituziANDO / iOS_画面遷移
Created August 28, 2012 05:42
iOS_画面遷移
ストーリーボード上でセグエにgoSampleというIDをつけておく
- (void)method
{
[self performSegueWithIdentifier:@"goSample" sender:self];
}
// 画面遷移する前に呼ばれる
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
@HituziANDO
HituziANDO / Java_ServletのPrintWriter出力
Created August 28, 2012 15:38
Java_ServletのPrintWriter出力
resp.setContentType("text/html; charset=UTF-8");
PrintWriter out = resp.getWriter();
この順番じゃないと文字化けする
@HituziANDO
HituziANDO / Java_EkiDataApi
Created August 29, 2012 03:29
Java_EkiDataApi
public class NearestSta
{
Coord coord;
List<Station> station = new ArrayList<Station>();
}
public class Coord
{
public float lon; // Request longitude
public float lat; // Request latitude
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self startSensor];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
@HituziANDO
HituziANDO / file_handler.php
Created August 7, 2013 01:53
ファイル入出力スニペットです。
<?php
function read_file ($filename)
{
$str = null;
$fp = fopen($filename, 'r');
if ($fp) {
if (flock($fp, LOCK_EX)) {
$str = '';
@HituziANDO
HituziANDO / geo_distance2.php
Created August 7, 2013 14:10
2地点間距離の二乗を計算します
<?php
/**
* input: 2点の緯度経度(10進数)
* output: 2点間距離の2乗(km^2)
*/
function geo_distance2 ($lat1, $lng1, $lat2, $lng2) {
$earth_r = 6378.137; // 地球の半径(km)
$deltaLat = deg2rad($lat2 - $lat1); // 緯度差(角度ラジアン)
$deltaLng = deg2rad($lng2 - $lng1); // 経度差(角度ラジアン)
@HituziANDO
HituziANDO / prevent.css
Created August 14, 2013 15:10
HTML長押しで出てくるAlertView等を封印します。
* {
/* prevent callout to copy image, etc when tap to hold */
-webkit-touch-callout: none;
/* prevent webkit from resizing text to fit */
-webkit-text-size-adjust: none;
/* make transparent link selection, adjust last value opacity 0 to 1.0 */
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
/* prevent copy paste, to allow, change 'none' to 'text' */
-webkit-user-select: none;
}
@HituziANDO
HituziANDO / selector.html
Last active December 21, 2015 01:59
HTMLでプルダウンリストの選択した値の取得方法をよく忘れてしまうのでメモ。
<select id="selXxx" onchange="onChange(this)">
<option value="hoge" selected>hoge</option>
<option value="foo">foo</option>
<option value="bar">bar</option>
</select>
<script>
function onChange (selector) {
var val = selector.options[selector.selectedIndex].value;
if (val == "hoge") {
@HituziANDO
HituziANDO / iOS_StatusBar
Last active August 29, 2015 14:15
iOSのステータスバースタイル変更
// info.plistの"View controller-based status bar appearance"をYESにする
// 各ViewControllerで下記のように実装する
// "View controller-based status bar appearance"をNOにした場合はinfo.plistの"Status bar style"が全ViewControllerに適用される
// "View controller-based status bar appearance"をinfo.plistに追加していない場合は変更は適用されない
- (void) viewDidLoad {
[super viewDidLoad];
// 変更を通知
if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {
[self setNeedsStatusBarAppearanceUpdate];