Skip to content

Instantly share code, notes, and snippets.

View trandaison's full-sized avatar

Son Tran trandaison

View GitHub Profile
@trandaison
trandaison / rspec_rails_cheetsheet.rb
Created September 12, 2017 07:25 — forked from redrick/rspec_rails_cheetsheet.rb
New expect syntax + new hash syntax and couple corrections
#Model
expect(@user).to have(1).error_on(:username) # Checks whether there is an error in username
expect(@user.errors[:username]).to include("can't be blank") # check for the error message
#Rendering
expect(response).to render_template(:index)
#Redirecting
expect(response).to redirect_to(movies_path)
@trandaison
trandaison / rspec_rails_cheetsheet.rb
Created September 12, 2017 07:25 — forked from them0nk/rspec_rails_cheetsheet.rb
Rspec Rails cheatsheet (include capybara matchers)
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
@trandaison
trandaison / excel_xlsx_schema.xml
Created September 11, 2017 01:38
MS Office schema
<?xml version="1.0"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<Author>Microsoft Office User</Author>
<LastAuthor>Microsoft Office User</LastAuthor>
<Created>2017-09-11T01:32:10Z</Created>
require 'formula'
class Varnish3 <Formula
url 'https://varnish-cache.org/_downloads/varnish-3.0.2.tgz'
homepage 'http://www.varnish-cache.org/'
sha256 '973f60625e9690e0989e1bbc73c37ea53fc6291b8f7b03d617b76f8084a4a243'
depends_on 'pkg-config' => :build
depends_on 'pcre' => :build
@trandaison
trandaison / install_ruby.md
Created June 12, 2017 09:49
Install Ruby using RVM
  1. install RVM
\curl -sSL https://get.rvm.io | bash -s stable
  1. List all ruby versions
rvm list known
  1. Install a version of Ruby
@trandaison
trandaison / atom_snippets.cson
Last active May 24, 2017 07:43
Atom configs
'.source.ruby':
'Redirect to':
'prefix': 'redi'
'body': "redirect_to ${1:some}_path"
'flash[:key] = value':
'prefix': 'flash'
'body': 'flash[${1::success}] = ${2:"Created successfully."}$3'
'render json':
'prefix': 'renjson'
@trandaison
trandaison / starUML.md
Last active May 2, 2024 10:02
Get full version of StarUML
<html>
<head>
<title>Google Maps Multiple Markers</title>
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
</head>
<body>
<div id="map" style="height: 400px; width: 500px;">
</div>
<script type="text/javascript">
@trandaison
trandaison / nodejs_on_ubuntu.md
Last active March 29, 2017 00:37
Install Nodejs on Ubuntu
sudo apt-get install npm
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
sudo ln -sf /usr/local/n/versions/node/<VERSION>/bin/node /usr/bin/node 

To upgrade to latest version (and not current stable) version, you can use

@trandaison
trandaison / whenever.md
Last active January 15, 2020 17:08
Simple example about Whenever gem

#Add sidekiq, sinatra and whenever to the Gemfile

gem 'sidekiq'
gem 'sinatra', require: false
gem "whenever", require: false

Then install the gem

$ bundle install