Skip to content

Instantly share code, notes, and snippets.

View bibstha's full-sized avatar
💭
🇳🇵🇨🇦

Bibek Shrestha bibstha

💭
🇳🇵🇨🇦
  • Vancouver, Canada
  • 20:30 (UTC -08:00)
View GitHub Profile
@bibstha
bibstha / deploy.rb
Created September 16, 2013 09:54
Integrate whenever with capistrano. Add the following lines to automatically update crontab after cap deploy
set :whenever_command, "bundle exec whenever"
set :whenever_identifier, defer { "#{:myappname}_#{:production}" }
require "whenever/capistrano"
after "deploy:restart", "whenever:update_crontab"
<a href="javascript:var l = document.location; new_href = l.origin + '.eaccess.ub.tum.de' + l.pathname + l.search; window.location.href = new_href">Access with TUM</a>
require 'ruleby'
include Ruleby
class CoffeeOperationRulebook < Rulebook
# Note the rules do not have to be in order
def rules
rule [Machine, :m, m.status == :GRINDING] do |v, e|
puts "Grinding complete, puring coffee"
v[:m].status = :POURING
e.modify v[:m]
@bibstha
bibstha / gist:49540af53fa0ec5ab869
Last active February 5, 2021 07:47
Deploy to dokku from codeship.com

After migrating from heroku to dokku, we had to also chance codeship so we deploy to dokku. I followed the following steps to successfully deploy to dokku.

  1. Save the public key of the codeship project. It is found in Project Settings > General Settings.
  2. Copy the public key to a file /tmp/codeship_projectname.pub.
  3. Make sure when pasting, all the contents are in a single line and not multiple lines.
  4. Add the public key to dokku using the following command in console. Reference.
cat /tmp/codeship_projectname.pub | ssh root@yourdokkuinstance "sudo sshcommand acl-add dokku [description]"

Some intermediate tips for VIM enthusiasts

In the beginning, there was the basics:

Command Mode
i - Insert Mode
a - Insert after the character
I - Insert at the beginning of the line
A - Insert at the end of the line
module Quackable
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def has_voice(word)
@words ||= []
@words << word
end
@bibstha
bibstha / recipe.rb
Created May 18, 2016 12:42
recipe.rb
# step 1
git "/path/to/folder" do
repository "myrepo"
action :sync
end
# step 2
rubyversion = library_get_ruby_version_from_git_folder("/path/to/folder")
# step 3
require "bundler/inline"
gemfile(true) do
source 'https://rubygems.org'
gem 'concurrent-ruby-edge', require: 'concurrent-edge'
gem 'concurrent-ruby-ext'
end
require 'concurrent/channel'
require "bundler/inline"
gemfile(true) do
source 'https://rubygems.org'
gem 'concurrent-ruby-edge', require: 'concurrent-edge'
gem 'concurrent-ruby-ext'
end
require 'concurrent/channel'
@bibstha
bibstha / gist:934990fd24705210f570770aef6bb036
Created February 25, 2019 02:10 — forked from xdite/gist:1641818
RR-020 RR Object Oriented Programming in Rails with Jim Weirich http://asciirogues.com/

Jim: What I really like is that there are so many Ruby podcasts out there that are newsy. This one dives into technical issues, and I really enjoy that.

Charles: Hey everybody, and welcome back to the Ruby Rhodes podcast. This is your host Charles Max Wood, and this week on our panel we have a special guest rogue. I met him at the Rocky Mountain Ruby Conference in Boulder. He actually suggested this week's topic, so we're going to welcome Jim Weirich to the podcast.

Jim: Thanks for having me. Glad to be here.

Charles: Do you want to introduce yourself really quickly Jim for those one or two people that don't know who you are?

Jim: Sure, absolutely. Jim Weirich. I'm from Cincinnati, Ohio. I've been doing Ruby for over ten years now. I work for EdgeCase. I'm the chief scientist, and I've probably written software that you are using, such as Rake and various mocking frame works and some XML builder stuff, too. You're probably using some of my code somewhere.