Skip to content

Instantly share code, notes, and snippets.

View dahal's full-sized avatar
🤖
vibing

Puru Dahal dahal

🤖
vibing
View GitHub Profile
@dahal
dahal / PostalAddress.rb
Last active March 21, 2016 23:24 — forked from colinyoung/PostalAddress.rb
Parses a postal address into its components. (limited) i18n support and other features. inspired by this forrst post: http://forr.st/~zDa
#
# Most of the regexes here are from http://twitter.com/schuyler.
# They were posted on Forrst (http://forr.st/~zDa) as a public post,
# so I reworked them into a full class.
#
# Added:
# => (limited) international support -- should handle US/Canada and most of western europe
# => added :receipient, :postcode, and :country fields
# => state/province detection built-in

Deploy Rails 4 app with Dokku on DigitalOcean

Install dokku

First create a Ubuntu 13.04 x64 droplet on DigitalOcean Control Panel

Then ssh with root account, run this in termianl:

$ wget -qO- https://raw.github.com/progrium/dokku/master/bootstrap.sh | sudo bash
@dahal
dahal / buttons.html
Created April 16, 2016 00:16
Rent made Easy Styleguide
<!-- Anchors (links) -->
<a href="" class="button">Learn More</a>
<a href="" class="button">View All Features</a>
<!-- Buttons (actions) -->
<button type="button" class="success button">Save</button>
<button type="button" class="alert button">Delete</button>
@dahal
dahal / lambda-dynamo
Created May 4, 2016 04:32 — forked from markusklems/lambda-dynamo
Short aws lambda sample program that puts an item into dynamodb
// create an IAM Lambda role with access to dynamodb
// Launch Lambda in the same region as your dynamodb region
// (here: us-east-1)
// dynamodb table with hash key = user and range key = datetime
console.log('Loading event');
var AWS = require('aws-sdk');
var dynamodb = new AWS.DynamoDB({apiVersion: '2012-08-10'});
exports.handler = function(event, context) {
@dahal
dahal / flock.grid.html
Last active July 5, 2016 22:47
Styleguide
<div class="row">
<div class="one column">One</div>
<div class="eleven columns">Eleven</div>
</div>
<div class="row">
<div class="two columns">Two</div>
<div class="ten columns">Ten</div>
</div>
<div class="row">
<div class="three columns">Three</div>
@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>
@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="test@mailbox.com" 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.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 / 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 / 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")