Skip to content

Instantly share code, notes, and snippets.

View keepcosmos's full-sized avatar

Jaehyun Shin keepcosmos

View GitHub Profile
@keepcosmos
keepcosmos / mongoid_calendar_sample_model.rb
Last active August 29, 2015 13:57
Mongodb Calendar Sample Code
class Calendar::GuideCalendar
include Mongoid::Document
field :user_id, :type => Integer
has_many :event_date, :class => Calendar::EventDate
# event date 기간 삽입
def insert_duration(start_date, end_date)
self.insert_events(*(start_date..end_date).to_a)
@keepcosmos
keepcosmos / mongodb_groupby.js
Created April 10, 2014 05:06
mongo db group by count
db.messenger_rooms.group({
keyf: function(doc){
var date = new Date(doc.created_at);
date.setHours(date.getHours() + 9);
var dateKey = (date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate());
return {'day':dateKey};
},
cond: {created_at: {$gte: ISODate("2014-04-01"), $lte: ISODate("2014-04-03")}},
initial: { count: 0, reserved_count: 0},
reduce: function(doc, aggregator){
@keepcosmos
keepcosmos / mongodb_mapreduce_group_by.js
Last active August 29, 2015 13:58
mongodb mapreduce group by
db.messenger_rooms.mapReduce(
function(){
var date = new Date(this.created_at);
date.setHours(date.getHours());
var dateKey = (date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate());
var reserved_count = (this.reservation_status == undefined || this.reservation_status == null) ? 0 : 1;
emit(dateKey, {count: 1, reserved_count: reserved_count});
},
function(key, values){
var sum = {count: 0, reserved_count: 0}
@keepcosmos
keepcosmos / gist:d75bd50028385b71bda7
Created March 6, 2015 02:49
resolve bundler checkout error
# MOVE TO PROJECT PATH
rm -rf ~/.bundle/ ~/.gem/bundler/ ~/.gems/cache/bundler/
rm -rf $GEM_HOME/bundler/ $GEM_HOME/cache/bundler/
rm -rf .bundle/
rm -rf vendor/cache/
@keepcosmos
keepcosmos / gist:427bc2bcd1da27b71390
Created December 27, 2015 08:58 — forked from wacko/gist:5577187
SSH between Mac OS X host and Virtual Box guest

On Mac OS (host):

Shutdown your VM and do:

VirtualBox > Settings > Network > Add (you will get vboxnet0)

On a terminal ifconfig will show you new interface vboxnet0

VM's Settings > System > check "Enable I/O APIC." VM's Settings > Network > Adapter 2 > host-only vboxnet0

@keepcosmos
keepcosmos / gist:160446cb40bd9bf1d07e27522c906a8d
Created September 26, 2016 03:42 — forked from ryansobol/gist:5252653
15 Questions to Ask During a Ruby Interview

Originally published in June 2008

When hiring Ruby on Rails programmers, knowing the right questions to ask during an interview was a real challenge for me at first. In 30 minutes or less, it's difficult to get a solid read on a candidate's skill set without looking at code they've previously written. And in the corporate/enterprise world, I often don't have access to their previous work.

To ensure we hired competent ruby developers at my last job, I created a list of 15 ruby questions -- a ruby measuring stick if you will -- to select the cream of the crop that walked through our doors.

What to expect

Candidates will typically give you a range of responses based on their experience and personality. So it's up to you to decide the correctness of their answer.

@keepcosmos
keepcosmos / eventmachine.rb
Created January 9, 2017 13:08 — forked from joshuasiler/eventmachine.rb
Initializer that allows EventMachine to run within Rails, and work with AMQP, Passenger, Thin and Capybara
require 'amqp'
module HiringThingEM
def self.start
if defined?(PhusionPassenger)
PhusionPassenger.on_event(:starting_worker_process) do |forked|
# for passenger, we need to avoid orphaned threads
if forked && EM.reactor_running?
EM.stop
end
Thread.new {
@keepcosmos
keepcosmos / myrealtrip-commit-template.txt
Last active October 10, 2017 05:11
Myrealtrip Commit Template
# {type}: {요약된 내용을 한 줄로 작성}
# ex) fix: 공유용 여행확인증 URL에 파라미터로 포함된 access_token이 복호화되지 않는 문제 해결.
# 상세 내용이나 지라 이슈코드가 있다면, 명료하고 간결하게 아래에 작성합니다.
# --- COMMIT END ---
# type의 종류
# feature (새로운 기능)
# fix (버그 픽스)
@keepcosmos
keepcosmos / keybase.md
Created July 18, 2018 08:32
keybase.md

Keybase proof

I hereby claim:

  • I am keepcosmos on github.
  • I am keepcosmos (https://keybase.io/keepcosmos) on keybase.
  • I have a public key ASAwp-juGS27s8Nf-j-vii8202YtEAkRvo7j1HHEtK0UUgo

To claim this, I am signing this object:

@keepcosmos
keepcosmos / keybase.md
Created July 18, 2018 08:32
keybase.md

Keybase proof

I hereby claim:

  • I am keepcosmos on github.
  • I am keepcosmos (https://keybase.io/keepcosmos) on keybase.
  • I have a public key ASAwp-juGS27s8Nf-j-vii8202YtEAkRvo7j1HHEtK0UUgo

To claim this, I am signing this object: