Skip to content

Instantly share code, notes, and snippets.

View ochim's full-sized avatar

munehiro ochi ochim

View GitHub Profile
@re-fort
re-fort / kachidoki_elevator.cc
Last active February 24, 2017 11:06 — forked from remore/kachidoki_elevator.cc
(1: 最適化問題) 下記パラメータのままでElevator::tick()のみを最適化して平均待ち人数を最小化する / (2: 並列化問題) 以下のプログラムをマルチスレッドで動作させると何倍早くなるか実装して検証する / (3: チューニング問題)並列化以外の方法で本プログラムの実行時間を短縮するためにどのような改修を加えるとよいか考察する
#include <iostream>
#include <iomanip>
#include <random>
#include <unistd.h>
using namespace std;
const int MAX_FLOOR = 14;
const int ELEVATOR_COUNT = 4;
const int RAISING_PROBABILITY = 10;
@xhiroga
xhiroga / kotlinfest2019.md
Last active January 3, 2020 04:19
Kotlin Fest 2019 登壇資料まとめ
import UIKit
extension UIScrollView {
struct DefaultProperty {
let contentOffset: CGPoint
let contentSize: CGSize
let contentInset: UIEdgeInsets
let zoomScale: CGFloat
}
@jdewind
jdewind / gist:1204051
Created September 8, 2011 17:41
Capture the entire contents of a UITableView or UIScrollView
static UIImage* CreateImageFromView(UITableView *view)
{
UIGraphicsBeginImageContextWithOptions(CGSizeMake(view.contentSize.width, view.contentSize.height), NO, 0.0f);
CGContextRef context = UIGraphicsGetCurrentContext();
CGRect previousFrame = view.frame;
view.frame = CGRectMake(view.frame.origin.x, view.frame.origin.y, view.contentSize.width, view.contentSize.height);
[view.layer renderInContext:context];
view.frame = previousFrame;
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
@daichan4649
daichan4649 / RecordTest.java
Last active February 19, 2021 12:03
外部レコーダ(音声/動画)起動後に、保存データ(録音/録画)を取得 (Android)
private static final int REQ_CODE_MIC = 0;
private static final int REQ_CODE_MOVIE = 1;
private void startAudioRecorder() {
Intent intent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION);
try {
startActivityForResult(intent, REQ_CODE_MIC);
} catch (Exception e) {
e.printStackTrace();
}
@Pooh3Mobi
Pooh3Mobi / LifeCycleObserveableLogger.kt
Last active April 23, 2021 11:20
LifeCycleObserveableLogger
import android.util.Log
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.OnLifecycleEvent
object IndentProvider {
private var depth = 0
private const val SPACE = " "
@KentarouKanno
KentarouKanno / WKWebView.md
Last active March 30, 2023 17:24
WKWebView

WKWebView

import UIKit
import WebKit

class ViewController: UIViewController, WKNavigationDelegate {
    
    var wkWebView: WKWebView!
    let observerKeyName = ["estimatedProgress", "loading", "title", "URL", "hasOnlySecureContent", "canGoBack", "canGoForward"]
@aphlysia
aphlysia / stfuawsc_itg_advent2014_4_conda.md
Last active June 16, 2023 01:05
conda で python の環境つくり

これは stfuawsc_itg Advent Calendar 2014 4日目の記事です。

プログラミングをしていると、いろいろなバージョンの環境を行ったり来たりしたくなることがあります。たとえば言語処理は python 2 へ nltk を入れてやりたい。シミュレーションは python 3 へ numpy 入れてやりたいとか。
そういうふうに言語やモジュールのバージョンをいろいろ組合せた環境を気軽に切り替えられると便利です。
実際そういうことを可能にするツールはたくさんあります。virtualenv, pyenv など。
ここで紹介する conda というツールもその1つです。
virtualenv などでは、モジュールを入れるときは通常の python の流儀でインストールするのですが、インストールがうまくいかないというのはよくあることです。conda ではあらかじめビルドされたものを入れるので、楽です。もちろん conda に用意されていないモジュールもありますが、そういうのは pip 等通常の方法で入れて共存できます。

ではさっそく conda で python の環境を作る方法です。

@brennanMKE
brennanMKE / directoryExistsAtPath.swift
Created April 20, 2017 22:23
Directory Exists at Path in Swift
fileprivate func directoryExistsAtPath(_ path: String) -> Bool {
var isDirectory = ObjCBool(true)
let exists = FileManager.default.fileExists(atPath: path, isDirectory: &isDirectory)
return exists && isDirectory.boolValue
}
@shinyaohira
shinyaohira / App States and Multitasking.md
Last active October 5, 2023 07:57
アプリケーションの状態とマルチタスキング

全体的に簡略化し、必要と思われる部分を抜粋しました。

  • Not running

    アプリは起動されていないか、実行されていたけれどもシステムによって終了されています。

  • Inactive