Skip to content

Instantly share code, notes, and snippets.

View xirukitepe's full-sized avatar
🙈
See No Evil

Shi xirukitepe

🙈
See No Evil
View GitHub Profile
@xirukitepe
xirukitepe / Better Database Pulling With Heroku
Created November 23, 2012 06:44 — forked from jackkinsella/Better Database Pulling With Heroku
Taps isn't reliable for anything but dummy databases. This command invokes the more powerful PGBackups. A side effect is that every time you pull your database locally a backup is also generated on your server.
#!/bin/bash
# Best use case is to create a file "update_local_db.sh" in your project folder and then call the command with bash update_local_db
# Follow me: @jackkinsella
function LastBackupName () {
heroku pgbackups | tail -n 1 | cut -d"|" -f 1
}
# This part assumes you have a low limit on no. of backups allowed
@xirukitepe
xirukitepe / rails.org
Created March 11, 2013 06:54 — forked from map7/rails.org

Security is Hard

Massive Assignment

  • watch for ActiveRecord Relation, like has_many, has_many :through
  • watch for user_roles, `group_users
  • UPDATE action

Admin

# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
# gem install mysql2
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql2
encoding: utf8
@xirukitepe
xirukitepe / zsh.md
Last active August 29, 2015 14:20 — forked from tsabat/zsh.md
@xirukitepe
xirukitepe / capybara cheat sheet
Created April 20, 2016 02:27 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@xirukitepe
xirukitepe / friendly_urls.markdown
Created June 2, 2016 00:19 — forked from jcasimir/friendly_urls.markdown
Friendly URLs in Rails

Friendly URLs

By default, Rails applications build URLs based on the primary key -- the id column from the database. Imagine we have a Person model and associated controller. We have a person record for Bob Martin that has id number 6. The URL for his show page would be:

/people/6

But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6 here, is called the "slug". Let's look at a few ways to implement better slugs.

curl -XGET http://localhost:9200/store_development_products/_search -d '
{
"aggs": {
"category_ids": {
"terms": {
"field": "root_category_ids",
"size": 1000
},
"aggs" : {
"by_product_type": {