Skip to content

Instantly share code, notes, and snippets.

View arvindang's full-sized avatar

Arvin Dang arvindang

View GitHub Profile
@arvindang
arvindang / devise.md
Created November 16, 2016 01:39 — forked from raghubetina/devise.md
Devise Cheatsheet

Authentication and Authorization with Devise

We will be using the [Devise gem][2] to help us get started with authentication (are you who you say you are?) and authorization (are you allowed to do/see this?).

Add sign-in/sign-out

  • Add gem 'devise' to your Gemfile and bundle
  • rails g devise:install

Devise will give you some setup instructions. We don't need to worry about most of them, but we do need to set a root URL. Usually, you will point the root URL to the index action of some important resource in your application: In config/routes.rb:

@arvindang
arvindang / idea_mapping.md
Created October 26, 2016 21:25 — forked from raghubetina/idea_mapping.md
Idea Mapping

1. Pain Points

You should think of a couple of pain points in your life that you would like to solve with a simple CRUD app. Remember,

The verb you want to be using with respect to startup ideas is not "think up" but "notice." — [Paul Graham, "How to Get Startup Ideas"][1]

Don't try to think up billion dollar startup ideas; our goal here is to discover a good first learning project, not to save the world just yet. Try to notice a real annoyance at work or at home or with friends that we can solve, even if for just one user -- you.

For example, [here is a project that a student made last quarter][2] -- a simple app that lets you keep track of whether or not it's time to dry clean pieces of clothing. Another student made a nice app that suggests which of your credit cards to use in order to maximize rewards based on what kind of purchase you are about to make.

@arvindang
arvindang / crud_with_ruby.md
Created October 26, 2016 21:25 — forked from raghubetina/crud_with_ruby.md
CRUD with Ruby

CRUD with Ruby

Here is a quick reference on how to insert, retrieve, update, and delete rows from your database tables using our ActiveRecord-backed Ruby classes.

Adding Tables to the Database

First, we need a Ruby class to represent the real-world thing we're trying to model, and we need an underlying database table to store information about each individual thing.

Rails includes an easy generator to help us get set up with both of these things quickly. Supposed I wanted to create a table to store instructors, with two string columns first_name and last_name. I could use this shortcut from the Command Line:

@arvindang
arvindang / Sticky header using waypoint plugin
Created December 22, 2014 16:32
Sticky header using waypoint plugin
$('#opening, #film, #practical, #conference, #guide')
.waypoint(function(direction) {
// sticky header
$(this).find('> div > header').toggleClass('sticky', direction === 'down');
// nav .current
currentNav($(this).attr('id'), direction === 'down');
})
.waypoint(function(direction) {
@arvindang
arvindang / Calc() Grid System
Created December 18, 2014 20:41
Grid system using calc
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script>
.grid-box {
float: left;
@arvindang
arvindang / jsbin.saduz.css
Created April 29, 2014 00:09
Card hover and reveal on click.
body {
padding-top: 40px;
}
div {
height: 250px;
overflow: hidden;
width: 370px;
transition: all .2s ease-in;
margin: 0 auto;
@arvindang
arvindang / jsbin.wuler.css
Created April 28, 2014 19:14
Creating text with a gradient background with just CSS. Very iOS 7.
body {
padding: 10px;
}
p {
background: -webkit-linear-gradient(top,#fd0b58 0,#a32b68 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
@arvindang
arvindang / .bash_profile
Created February 17, 2014 15:50
Bash Profile
function reload {
source ~/.bash_profile
}
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo " *"
}
function parse_git_branch {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
@arvindang
arvindang / index.html
Last active December 29, 2015 04:59
Three way toggle
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-git2.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<!-- <a href="#">
<img class="static" src="http://placekitten.com/100/100" alt="">
@arvindang
arvindang / jsbin.owOKuCuK.html
Created October 21, 2013 16:44
Use jQuery to change link copy and URL on hover.
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-git2.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<a href="http://google.com">Google</a>