Skip to content

Instantly share code, notes, and snippets.

View raven38's full-sized avatar

raven raven38

View GitHub Profile
@raven38
raven38 / Brewfile
Last active May 30, 2022 15:45
Brewfile
tap "golangci/tap"
tap "gromgit/fuse"
tap "grpc/grpc"
tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/core"
tap "kyoshidajp/ghkw"
tap "px4/px4"
brew "a2ps"
brew "arp-scan"
@raven38
raven38 / noglobal.py
Created December 6, 2020 08:23 — forked from yoshipon/noglobal.py
Useful Noglobal in Python
# License:
# I hereby state this snippet is below "threshold of originality" where applicable (public domain).
#
# Otherwise, since initially posted on Stackoverflow, use as:
# CC-BY-SA 3.0 skyking, Glenn Maynard, Axel Huebl
# http://stackoverflow.com/a/31047259/2719194
# http://stackoverflow.com/a/4858123/2719194
import builtins
import types
from chainer import cuda
from chainer import function
from chainer.utils import type_check
import numpy as np
import cupy as cp
def _kern():
return cuda.elementwise(
'T cond, T x, T slope', 'T y',
fruits = ['apple', 'banana', 'grape']
for fruit in fruits:
print(fruit)
@raven38
raven38 / file0.txt
Created February 14, 2015 09:15
OS XでGNATをインストールする方法 ref: http://qiita.com/raven38/items/c71a500a9b2ca9c93dd0
$ cd
$ tar zxvf ~/Downloads/gnat-gpl-2014-x86_64-darwin-bin.tar.gz
$ cd gnat-gpl-2014-x86_64-darwin-bin
$ sudo ./doinstall
@raven38
raven38 / ceil_floor_round.md
Last active August 29, 2015 14:11
天井関数、割り算の切り上げ

m/nを切り上げる

(m + n - 1) / n

m/nを切り下げる

m / n

m/nを四捨五入する

@raven38
raven38 / concatvec.cpp
Created November 10, 2014 16:28
vector<string>の要素を全て繋げてstringにする
#include <numeric>
using namespace std;
// T accumulate( InputIt first, InputIt last, T init );
string concatvec(vector<string> expr){ return accumulate(expr.begin(), expr.end(), string(""));}
int main(){
vector<string>vs; // 適当な文字列を入れてく
string s = concatvec(vs);
@raven38
raven38 / combination.cpp
Created October 15, 2014 12:31
小さい方のcombination
long long combination(int n, int r){
long long i = 1;
int k = r>n-r?n-r:r, cnt;
if(k < 0) return 0;
for(cnt = 1; cnt <= k; cnt++){
i *= n - cnt + 1;
i /= cnt
}
return i;
}
@raven38
raven38 / combination.cpp
Created October 15, 2014 11:11
組み合わせの総数を求める。 combination
#define MOD 100000007
long long comb(int P_, int Q_){
static const int N_ = 1020;
static long long C_[N_][N_];
if(C_[0][0]==0){
int i,j;
for(i = 0; i < N_; ++i) C_[i][0] = C_[i][i] = 1;
for(i = 0; i < N_; ++i) for(j = 1; j < i; ++j) C_[i][j] = (C_[i-1][j-1] + C_[i-1][j])%MOD;