This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
begin | |
require 'bundler/inline' | |
rescue LoadError => e | |
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler' | |
raise e | |
end | |
gemfile(true) do | |
source 'https://rubygems.org' | |
gem 'rails', '5.1.2' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/HubSpot/react-select-plus | |
// rough sample code for rendering dropdown menu outside the Select DOM | |
import {Component} from 'react'; | |
import {createPortal, findDOMNode} from 'react-dom'; | |
import Select from 'react-select-plus'; | |
class Selector extends Component { | |
constructor(props){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// shared config (dev and prod) | |
const webpack = require('webpack'); | |
const {resolve} = require('path'); | |
const WebpackBuildNotifierPlugin = require('webpack-build-notifier'); | |
const HappyPack = require('happypack'); | |
const nodeEnv = process.env.NODE_ENV || 'development'; | |
var envConfig; | |
try { | |
const json = require(`../environments/${nodeEnv}.json`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#======= controller | |
def new | |
@model_a = ModelA.new | |
@model_a_param = ModelAParam.new | |
end | |
def create | |
@model_a_param = params[:model_a_param] # strong_parameterは省略ね | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include<cmath> | |
#include<cstdlib> | |
#define N 10 | |
#define E 0.001 | |
using namespace std; | |
double getRand(){ | |
int sign; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
debt = ARGV[0].to_i | |
pay = ARGV[1].to_i | |
interest_y = 18/100 | |
interest_m = interest_y/12 | |
month=0 | |
while true | |
break if(debt<=0) | |
debt = debt - pay + (debt * interest_m) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'open-uri' | |
require 'nokogiri' | |
class CookpadInspector | |
def initialize(recipe_id) | |
@doc = Nokogiri::HTML(open("http://cookpad.com/recipe/#{recipe_id.to_i}")) | |
end | |
def get_title | |
@doc.css("h1")[0].inner_html.strip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Hand | |
@@HANDS = ['G', 'T', 'P'] | |
@@WIN = 2 | |
@@LOSE = 1 | |
@@DRAW = 0 | |
attr_reader :int_hand, :str_hand | |
def initialize(str_hand) | |
@str_hand = str_hand |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ruby1.8以前では正常に動作しない可能性あり | |
def get_first_unique_char(str) | |
str.split('').inject(Hash.new(0)){|memo, v| memo[v]+=1; memo}.select{|k,v| v==1}.first[0] | |
end | |
$*.each {|v| p get_first_unique_char(v)} |