Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

omochimetaru omochi

🏠
Working from home
  • japan
  • tokyo
Block or report user

Report or block omochi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ika_ink.rb
def get_main_eff(gear)
1.0 - ((0.99 * gear) - (0.09 * gear)**2) / 75.0
end
def get_sub_eff(gear)
1.0 - ((0.99 * gear) - (0.09 * gear)**2) / 120.0
end
shield_default_cost = 0.60
ink_after_default_shield = 1.00 - shield_default_cost
View gcc_crash.cpp
// with gcc 4.8.2
#include <cstdio>
#include <functional>
int death = 1;
class Cat {
public:
std::function<void()> callback_;
@omochi
omochi / perm_suc.c
Created Dec 17, 2012
順列列挙をイテレータ的に書く。再帰のと違ってユーザにコールバックが要らないのが良い。インターフェースは揃わなかった。
View perm_suc.c
//gcc -std=c99
#include<stdio.h>
#include<stdlib.h>
void swap_int(int *a,int *b){
int t = *a;
*a = *b;
*b = t;
}
void reverse_int_array(int array[],int num){
for(int i=0;i<num/2;i++){
@omochi
omochi / file0.txt
Created Apr 26, 2013
ARCとMRCを混ぜながらプログラムを書くための方法とその調査報告 ref: http://qiita.com/omochi@github/items/f27022d31e9914af30b8
View file0.txt
How do I think about ARC? Where does it put the retains/releases?
Try to stop thinking about where the retain/release calls are put and think about your application algorithms instead. Think about “strong and weak” pointers in your objects, about object ownership, and about possible retain cycles.
View lazy_implementation_expection
$ swift
Welcome to Apple Swift version 2.1.1 (swiftlang-700.1.101.15 clang-700.1.81). Type :help for assistance.
1>
2.
3. class Cat {
4. lazy var voice: String = self.nya()
5. func nya() -> String {
6. return "nya"
7. }
8. deinit {
View angular2-tutorial-exp-main.js
System.register(['angular2/platform/browser', './app.component'], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var browser_1, app_component_1;
var Cat, cat1, cat2, cat3;
return {
setters:[
function (browser_1_1) {
browser_1 = browser_1_1;
},
View temp.kt
fun main(args: Array<String>) {
// valは定数(再代入禁止)
val a = 3
// if文が三項演算子みたいに機能するので定数定義の右辺値にできる。
// さらにifとelseの本文両方からの型推論が効いて、bの型はStringになっている
val b = if (a > 1) {
"big"
} else {
"small"
}
View kotlin-bug.kt
class A() {
init {
val s: String = getStr()
println("${s.length}") // java.lang.NullPointerException
}
fun getStr(): String {
return str
}
View q2er.txt
xyz
a = cx*cy*cz + sx*sy*sz
b = cy*cz*sx - cx*sy*sz
c = cx*cz*sy + cy*sx*sz
d = -cz*sx*sy + cx*cy*sz
xzy
a = cx*cy*cz - sx*sy*sz
b = cy*cz*sx + cx*sy*sz
c = cx*cz*sy + cy*sx*sz
View method-closure.kt
// こんなふうにメソッドをいろいろ呼び出して設定するようなやつがいるときに
class HogeBuilder {
fun configureAaa() { println("a") }
fun configureBbb() { println("b") }
fun configureCcc() { println("c") }
}
// こういう、「Tを引数にとる関数」があると
fun <T> myLet(x: T, f: (T)->Unit) {
You can’t perform that action at this time.