Skip to content

Instantly share code, notes, and snippets.

@jnst
jnst / README.md
Last active September 5, 2018 02:34 — forked from matsukaz/.gitignore
Google Protobuf v3.6.1 Build Script for iOS

Google Protobuf - Mac OS X and iOS Support

The script in this gist will help you buid the Google Protobuf library for use with Mac OS X and iOS. Other methods (such as homebrew or direct compilation) have issues that prevent their use. The libraries built by this script are universal and support all iOS device architectures including the simluator.

Get the Script

The easiest way to use this script is to simply clone the gist onto your

@jnst
jnst / gen_grpc_cpp.sh
Created August 27, 2018 08:46
Generate gRPC code by docker and Copy generated files to local.
#! /bin/bash
IMAGE_NAME=gen-grpc-cpp
CONTAINER_NAME=codegen-cpp
SRC_DIR=/workspace/codegen/rpc
DEST_DIR=./codegen
# change working directory to project root
cd $(dirname $0)/../
@jnst
jnst / Dockerfile
Created August 27, 2018 08:26
Generating gRPC C++ code
FROM grpc/cxx
WORKDIR /workspace
RUN mkdir codegen
COPY ./protobuf /workspace/protobuf
CMD protoc \
--proto_path=./protobuf \
--grpc_out=./codegen --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` \
./protobuf/rpc/*.proto \
@jnst
jnst / Dockerfile
Created August 10, 2018 06:00
Nginx by Alpine Linux
FROM nginx:mainline-alpine
HEALTHCHECK --interval=5s --timeout=3s --start-period=5s --retries=1 \
CMD wget -q -O - http://localhost/ || exit 1
CMD ["nginx", "-g", "daemon off;"]
@jnst
jnst / array.rb
Last active November 20, 2019 23:46
Difference of max and max_by in Ruby
array = [
{ id: 1, lv: 56 },
{ id: 2, lv: 12 },
{ id: 3, lv: 38 },
{ id: 4, lv: 99 },
{ id: 5, lv: 27 },
]
p array.max { |a, b| a[:lv] <=> b[:lv] } # => {:id:4, lv:99}
p array.max_by { |v| v[:lv] } # => {:id:4, lv:99}
@jnst
jnst / test.md
Last active November 29, 2016 19:30
def sample()
  p 'hello, world'
end
$ echo hello
hello
@jnst
jnst / .vimrc
Created November 11, 2016 08:18
Vim設定-2016-11-11
" ================ General Config ====================
set encoding=utf-8
set autoread
" ================ Editor Display ====================
set number
set title
set ruler
set cursorline
set nowrap
@jnst
jnst / add_trigger_to_room_chat.rb
Created September 28, 2016 05:59
ActiveRecord + MySQL Trigger
class AddTriggerToClanChat < ActiveRecord::Migration
# MySQL のトリガーは同テーブルへの変更が不可能なため実行時にエラーとなる
def up
execute <<-SQL
CREATE TRIGGER trigger_delete_chat AFTER INSERT ON room_chats
FOR EACH ROW
BEGIN
DECLARE num INT;
SELECT COUNT(*) INTO num FROM room_chats WHERE room_id = new.room_id;
@jnst
jnst / performance.cpp
Created July 26, 2016 08:44
C++11で処理速度の計測
auto start = std::chrono::system_clock::now();
// -----
// 処理
// -----
CCLOG("1: %lld マイクロ秒", std::chrono::duration_cast<chrono::microseconds>(chrono::system_clock::now() - start).count());
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.BufferedOutputStream;
import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;