Skip to content

Instantly share code, notes, and snippets.

View dahal's full-sized avatar
🌟
captableinc/captable

Puru Dahal dahal

🌟
captableinc/captable
View GitHub Profile
@dahal
dahal / rails_helper.rb
Created March 30, 2018 21:01 — forked from stevehanson/rails_helper.rb
Webpacker - When running tests, compile only if necessary
# spec/rails_helper.rb
require_relative 'support/webpack_test_helper.rb'
# ...
config.before(:suite) do
# Compile webpack if necessary.
# Only runs if checksum of JS files has changed
WebpackTestHelper.compile_webpack_assets
end
@dahal
dahal / easy_rails_deployment_with_capistrano.md
Created December 7, 2017 00:51
Easy Rails deployment with Capistrano

Goals of this tutorial:

  • deploy a new Rails app with capistrano
  • make it fast (total process takes less than 5 minutes)
  • make it simple (no unecessary config)
  • manual ssh to the server not required

Rails application stack:

  • nginx
  • unicorn
  • postgresql
console.log(`%c ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::
@dahal
dahal / Procfile
Created October 9, 2017 21:17 — forked from arches/Procfile
A little hack to restart Heroku web dynos when they hit 1000MB of memory
monitor: bundle exec ruby monitor.rb
@dahal
dahal / instant_articles.rb
Created August 30, 2017 17:47 — forked from kkyouhei/instant_articles.rb
Instant Articles API for Ruby
require 'net/http'
page_id = "your page id"
access_token = "your access token"
html_source = "your html content"
uri = URI.parse("https://graph.facebook.com/v2.6/#{page_id}/instant_articles")
request = Net::HTTP::Post.new(uri.path)
request.set_form_data({
access_token: access_token,
@dahal
dahal / threeio.rb
Created August 16, 2017 04:26 — forked from tlehman/threeio.rb
List all available three-character .io domain names (depends on colorize)
require 'net/http'
require 'colorize'
# find all available three-letter .io domains
alph = ('a'..'z')
# generate all three-character strings
threes = alph.map { |a| alph.map { |b| alph.map { |c| "#{a}#{b}#{c}" } } }.flatten
def io_available?(tld)
url = URI.parse("http://www.nic.io/cgi-bin/whois?query=#{tld}.io")
@dahal
dahal / registrations_controller.rb
Created December 13, 2016 00:40 — forked from jwo/registrations_controller.rb
API JSON authentication with Devise
class Api::RegistrationsController < Api::BaseController
respond_to :json
def create
user = User.new(params[:user])
if user.save
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201
return
else
@dahal
dahal / flock.lists.html
Created July 6, 2016 17:55
Flock Styleguide
<div class="six columns">
<ul>
<li>Unordered lists have basic styles</li>
<li>
They use the circle list style
<ul>
<li>Nested lists styled to feel right</li>
<li>Can nest either type of list into the other</li>
</ul>
</li>
@dahal
dahal / flock.forms.html
Created July 6, 2016 17:50
Flock Styleguide forms
<form>
<div class="row">
<div class="six columns">
<label for="exampleEmailInput">Your email</label>
<input class="u-full-width" type="email" placeholder="[email protected]" id="exampleEmailInput">
</div>
<div class="six columns">
<label for="exampleRecipientInput">Reason for contacting</label>
<select class="u-full-width" id="exampleRecipientInput">
<option value="Option 1">Questions</option>
@dahal
dahal / flock.buttons.html
Created July 5, 2016 22:48
Buttons for Flock styleguide
<button>Button</button>
<button class="button button-primary">Primary Button</button>
OR
<a class="button button-primary" href="#">Primary Button</a>
<a class="large-cta-button" href="#">Large CTA Button</a>