Skip to content

Instantly share code, notes, and snippets.

@joseche
joseche / .gemrc
Last active August 28, 2015 22:01
gemrc file with
:update_sources: true
:sources:
- http://gems.rubyforge.org
- http://gems.github.com
gem: --no-document
:verbose: true
:benchmark: false
:backtrace: false
@joseche
joseche / Rails Scaffold App
Last active September 8, 2015 01:42
This is how to create a rails app with forms and listings from an existing DB
1) get data into DB
2) make sure table names are PLURAL - ruby convention, models singular
3) point config/database.yml to DB and test: rails dbconsole, show tables
4) run "rake db:schema:dump" # generate db/schema.rb
5) run "gem install schema_to_scaffold"
6) run "scaffold"
Select a path to the target schema: 0 <- Hit enter
* for all tables
7) run each output command in same order, one by one
8) check routes "rake routes"
@joseche
joseche / .vimrc
Created September 8, 2015 17:30
My always changing .vimrc
syntax enable " enable syntax for known file ext ext
colorscheme darkblue " nice and available for most cases
set shiftwidth=4 " tab = 4 spaces
set tabstop=4
set expandtab " tabs are evil
set smartindent " use lang logic for indent
@joseche
joseche / rails_cheatsheet.md
Last active September 13, 2015 05:15
Basic rail commands

Rails cheatsheet

Use mysql as db eng

rails new newapp -d mysql

Generate scaffold content

rails generate scaffold Post title:string body:text author:references
@joseche
joseche / gitignore
Last active September 29, 2015 16:57
git ignore example file
.DS_Store
.foreman
.vagrant
.irb_history
.powrc
.rbenv-version
.ruby-version
.tm_properties
CREDENTIALS
*.pid
@joseche
joseche / key.sh
Last active October 27, 2015 22:51
Generate TLS self-signed certs
# generate self signed certificate:
openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -subj /CN=localhost -keyout cert.key -out cert.crt
# show contents of certficiate
openssl x509 -in cert.crt -text
@joseche
joseche / main.yml
Last active October 5, 2015 17:29
Ansible examples
---
- name: Ansible examples to copy & paste
hosts: all
vars:
firstvar: firstvalue
secondvar: secondvalue
roles:
- common
@joseche
joseche / tips.vim
Last active September 29, 2015 06:32
tips & tricks for using vim
# To see the current indenting settings, and where they were set, enter:
:verbose set ai? cin? cink? cino? si? inde? indk?
# Prevent auto indenting within that file, enter:
:setlocal noautoindent
:setlocal nocindent
:setlocal nosmartindent
:setlocal indentexpr=
@joseche
joseche / datasets.url
Last active November 12, 2017 22:05
Public Datasets
http://www.census.gov/popest/data/historical/2010s/vintage_2013/datasets.html
http://www.census.gov/popest/data/datasets.html
https://archive.org/download/stackexchange
http://www.datawrangling.com/some-datasets-available-on-the-web/
https://aws.amazon.com/datasets/
https://vincentarelbundock.github.io/Rdatasets/datasets.html
# Apache access logs:
http://ita.ee.lbl.gov/html/traces.html
@joseche
joseche / elasticsearch.url
Last active October 2, 2015 16:32
Elastic Search status urls
http://localhost:9200/_cluster/health
http://localhost:9200/_cat/nodes?v
http://localhost:9200/_cat/shards?v
http://localhost:9200/_cat/allocation?v
http://localhost:9200/_cluster/health?level=shards&pretty
http://localhost:9200/_cluster/state?pretty
http://localhost:9200/_cluster/stats?human&pretty
http://localhost:9200/_cat/master?v
http://localhost:9200/_cat/health?v