Skip to content

Instantly share code, notes, and snippets.

View danielmsong's full-sized avatar
💭
🤤

Daniel Song danielmsong

💭
🤤
View GitHub Profile
@danielmsong
danielmsong / index.html
Last active December 18, 2015 11:09 — forked from dbc-challenges/index.html
DBC Phase 2 Practice Assessment Part 3
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="http://cdn.jsdelivr.net/normalize/2.1.0/normalize.css">
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lato:100,900">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.0.2/css/font-awesome.min.css">
</head>
@danielmsong
danielmsong / legendary_rails_casts
Last active December 19, 2015 03:19
Legendary Rails Casts
Legendary Rails Casts
By Topic:
1. Testing
<a href="http://railscasts.com/episodes/257-request-specs-and-capybara">Request Specs and Capybara</a>
<a href="http://railscasts.com/episodes/275-how-i-test">How I Test(Guard & FactoryGirl)</a>

Importing/Exporting a Postgres DB from Heroku

In the following scenario, we have the following apps on the Heroku server:

  • Staging Server: staging-stackoverfluff
  • Production Server: stackoverfluff

In addition, each developer has a local development environment.

The goal is to move production data over to the staging server, and also provide production data to each of the developers. Here's what we will do.

Web Security

This post outlines three common web security vulnerabilities with specific examples in Rails. For a more complete list, I highly recommend the OWASP Rails security cheatsheet.

Cross-Site Scripting (XSS)

A cross-site scripting attack is when malicious scripts are injected into a web site in order to compromise it.

For example, let's say we want to allow html tags such as <strong> in our blog comments, so we render raw output using the Rails method #html_safe:

Definitions

General Testing

  • TDD Test Driven Development. Write examples before implementation.
  • BDD Behaviour-Driven Development is about implementing an application by describing its behavior from the perspective of its stakeholders. (The Rspec Book)
  • RSpec (mention alternatives, write a simple hand sewn test)

Testing Terms

Agile Software Development

Agile is a general philosophy describing a set of guiding principles for building software through iterative development. Agile development is about providing a framework that allows developers to build something useful for real world users and deal with the realities of interruptions, timelines, and technical requirements that disrupt an ideal development cycle. In other words, Agile development helps developers deal with reality.

SCRUM is a methodology -- in another words, an implementation -- pertaining specifically to project management. Other "Agile" methodologies inclue extreme programming, kanban.

SCRUM history:

Scrum was a term first used in 1987 to describe hyper-productive product development in Japan. The word Scrum comes from rugby, where scrum refers to the strategy used for getting an out-of-play ball back into play. The name Scrum stuck because of the similarities between the game of rugby and the type of product development prosc

@danielmsong
danielmsong / web_perf.md
Created July 1, 2013 13:43
web performance

to see web performance of your page, chrome has an add-on called Google PageSpeed

install gem 'rack-mini-profiler' to view diagnostics of page speed (backend)

  1. benchmarking
  2. profiling
  3. load testing- load w/ high # of inputs to see how testing scales
@danielmsong
danielmsong / travis_setup.md
Last active December 19, 2015 09:49
Travis Setup

Setting up travis is a pain in the ass. never liked that name.


Anyway, here are the steps I took to make it work for our app:

  1. go here and have the repo owner log into travis using github oAuth
  2. once you're logged into travis, you'll notice that your repo list is empty. go to the top right of the nav, drag down and click 'Accounts'. Turn the switch to 'on' for which repo you want travis to run on
  3. visit the github service hooks page (located under repo -> settings) and you should see that the travis hook has been activated with your github username and travis token. if not, fill those in
  4. add a '.travis.yml' file to your repository (where Rakefile and Gemfile are- not in a folder Here's what mine looked like:

Web Preformance

Sources of slow

Database

  • n+1 queries (try :includes or join)
  • Complex joins (is there another way to find the data?)
  • Missing indexes
  • Useless indexes
  • Schema (prossibly denormalize)
@danielmsong
danielmsong / lucas_benchmark.rb
Created August 27, 2013 03:45
lucas sequence benchmark
# we will benchmark our results to see just how much faster we can make this algorithm
require 'benchmark'
# original implementation
def lucas_number(n)
if n == 0
2
elsif n == 1
1
elsif n > 1