Skip to content

Instantly share code, notes, and snippets.

View create_pg_search_dcuments.rb
class CreatePgSearchDocuments < ActiveRecord::Migration[6.0]
def self.up
create_table :pg_search_documents do |t|
t.text :content
t.string :searchable_type
t.uuid :searchable_id
t.tsvector :content_tsvector
t.timestamps null: false
end
@patshaughnessy
patshaughnessy / ruby-book-club-questions.md
Last active Aug 18, 2017
Ruby Book Club Questions - Episodes 7 and 8
View ruby-book-club-questions.md

Hi guys, So in episode 7 you were asking about where and how the puts method connects to the computer’s display and writes the output. And in episode 8 you were asking about the times method, how that worked and why it wasn’t implemented with YARV instructions. In both cases, I didn’t go into detail about this in the book because it would have distracted you from the topic at hand, which is how YARV executes your code. (Or in this case, my example Ruby code from the book.)

Both the puts and times methods were written by the Ruby code team, and not by you or me. Both of them are implemented in C code. So when you’re writing a Ruby program, some of the methods you write yourself, but you get many other methods for free because they are part of the Ruby language. Many of the these built in methods are part of the standard library, which means they are Ruby code written by the Ruby core team, while other built in methods are written directly in C code by the Ruby team.

As you know, the puts method tak

View workstation.md

⚠️ this is now stupidly out of date

Computers

  • 13" Macbook Pro 3.3 GHz i7 (late 2016)
  • Microsoft Surface Book (2016)

Peripherals

@randycoulman
randycoulman / ViewControllerTests.swift
Last active Mar 5, 2016
Base class for view controller tests in Swift
View ViewControllerTests.swift
@testable import MyApp
import UIKit
import XCTest
class ViewControllerTests: XCTestCase {
var storyboard: UIStoryboard!
func storyboardName() -> String {
return "Main"
}
@rwarbelow
rwarbelow / running_app_in_production_locally.markdown
Created Nov 11, 2015
How to Run a Rails App in Production Locally
View running_app_in_production_locally.markdown
  1. Add gem 'rails_12factor' to your Gemfile. This will add error logging and the ability for your app to serve static assets.
  2. bundle
  3. Run RAILS_ENV=production rake db:create db:migrate db:seed
  4. Run rake secret and copy the output
  5. From the command line: export SECRET_KEY_BASE=output-of-rake-secret
  6. To precompile your assets, run rake assets:precompile. This will create a folder public/assets that contains all of your assets.
  7. Run RAILS_ENV=production rails s and you should see your app.

Remember to clobber your assets (rake assets:clobber) and re-precompile (rake assets:precompile) if you make changes.

@stefanneculai
stefanneculai / AWS_CONFIG.rb
Last active Jun 26, 2019
Amazon Signature Ruby
View AWS_CONFIG.rb
AWS_CONFIG = {
'access_key_id' => YOUR_ACCESS_KEY,
'secret_access_key' => YOUR_SECRET_ACCESS_KEY,
'bucket' => 'froala',
'acl' => 'public-read',
'key_start' => 'uploads/',
'region' => 's3' # For other regions than us-east-1, use s3-region. E.g.: s3-eu-west-1
}
@anotheruiguy
anotheruiguy / web-fonts-asset-pipeline.md
Last active Nov 29, 2021
Custom Web Fonts and the Rails Asset Pipeline
View web-fonts-asset-pipeline.md

Web fonts are pretty much all the rage. Using a CDN for font libraries, like TypeKit or Google Fonts, will be a great solution for many projects. For others, this is not an option. Especially when you are creating a custom icon library for your project.

Rails and the asset pipeline are great tools, but Rails has yet to get caught up in the custom web font craze.

As with all things Rails, there is more then one way to skin this cat. There is the recommended way, and then there are the other ways.

The recommended way

Here I will show how to update your Rails project so that you can use the asset pipeline appropriately and resource your files using the common Rails convention.

@jasonrudolph
jasonrudolph / about.md
Last active Nov 13, 2021
Programming Achievements: How to Level Up as a Developer
View about.md
View 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')