Skip to content

Instantly share code, notes, and snippets.

@k3komatsu
k3komatsu / gist:060de682297f947375dc
Last active August 29, 2015 14:03
C++11のdecltypeとenable_ifのif練習
#include <iostream>
#include <type_traits>
#include <vector>
extern void* enabler;
template<typename T>
constexpr auto has_begin(T* p) -> decltype((p->begin(), true))
{
@thinca
thinca / neobundle
Created August 22, 2012 02:14
neobundle command
#!/bin/sh
if [ -z "$1" ]; then
echo Usage: $0 {config-file}
exit
fi
vim -N -u NONE -i NONE -V1 -e -s --cmd "source $1" --cmd NeoBundleInstall! --cmd qall!
@komasaru
komasaru / unicorn_rails
Created January 7, 2013 02:56
Script to start unicorn.
#!/bin/sh
NAME="Unicorn"
ENV=production
ROOT_DIR="/var/www/rails/rails_app"
PID="${ROOT_DIR}/tmp/pids/unicorn.pid"
CONF="${ROOT_DIR}/config/unicorn.rb"
OPTIONS="--path /rails_app"
@rummelonp
rummelonp / Capfile
Created January 22, 2015 11:22
capistrano 3 でサブディレクトリをデプロイするやつ
require 'capistrano/git'
class Capistrano::Git
module SubDirectoryStrategy
include DefaultStrategy
def release
git :archive, fetch(:branch), fetch(:project_root), '| tar -x -C', release_path, "--strip=#{fetch(:project_root).count('/')+1}"
end
end
@teppeis
teppeis / gist:54cc85137e6b581a6f95
Last active May 18, 2017 02:35
Promise/非同期のテストを簡単にする新しいアサーションヘルパーのご紹介

Promise/非同期のテストを簡単にする新しいアサーションヘルパーのご紹介

この前のブログ記事見た人はごめん。

Promise/非同期のテストは難しい

どこが間違ってるか分かります?

@karloku
karloku / README.md
Last active March 30, 2018 07:28
Rails Template using GraphQL

This template is supposed to be applied to rails 5.

run with:

rails new <application_name> --template=https://gist.githubusercontent.com/karloku/edd6a158e275fdefa334/raw/b56175bee5b45d32310aeb620e23be44e3c2a56d/graphql_template.rb -T

using gems:

  • graphql
  • graphql-mutable_type
@aliang
aliang / mymodel.rb
Created June 13, 2011 06:25
render from model in Rails 3
# yes, sometimes you need to do this. you get pilloried in a forum if you
# ask about it, though!
# this code taken from
# http://wholemeal.co.nz/blog/2011/04/05/rendering-from-a-model-in-rails-3/
class MyModel < ActiveRecord::Base
# Use the my_models/_my_model.txt.erb view to render this object as a string
def to_s
ActionView::Base.new(Rails.configuration.paths.app.views.first).render(
@shirou
shirou / README
Last active October 8, 2018 14:53
ansible docker direct connection plugin
前提
-----------
- docker 0.9.1
- lxcを入れること
- linux 3.11で確認。 3.8以上じゃないとだめっぽい。
- ubuntu image (docker pull ubuntuで取ってきたもので試してみた)
- imageにはpython2を入れておくこと
- /usr/bin/tee がimageにあること
/* @flow */
import SHA256 from 'crypto-js/sha256'
type Block = {
index: number,
previousHash: string,
timestamp: number,
data: string,
hash: string
}
@sunaot
sunaot / eigenclass.md
Last active July 4, 2019 02:32
class << self によるクラスメソッドの定義のイディオムの説明とその背景にある特異クラスのかんたんな解説

Ruby のコードを読んでいると

class Hoge
  class << self
    def hello
      puts 'hello'
    end
  end
end