Skip to content

Instantly share code, notes, and snippets.

@kuahyeow
kuahyeow / controller_actions_keyword_args.rb
Last active October 2, 2020 18:03
a rewriter to upgrade to Rails 5.1 style controller test actions
=begin
USAGE: ruby-rewrite -l controller_actions_keyword_args.rb -m <FILE>
This rewriter moves your Rails controller tests from `get action, params, session, flash` to
`get action, params: params, session: session, flash: flash`.
Which is needed if you see the following message in your Rails 5.0 tests :
DEPRECATION WARNING: Using positional arguments in functional tests has been deprecated,
in favor of keyword arguments, and will be removed in Rails 5.1.
@slavikdev
slavikdev / cheatsheet.md
Created March 16, 2017 17:54
Rails request path cheatsheet

Rails request path cheatsheet

Full path with query string

>>  request.url
=> "http://localhost:3000/ask-help.amp?hui=pizda"

Virtual path without query string

>>  request.path
=&gt; "/ask-help.amp"
@sobstel
sobstel / nokogiri_install
Created January 3, 2017 17:30
nokogiri -> ERROR: cannot discover where libxml2 is located on your system
# `ERROR: Error installing nokogiri:
# ERROR: Failed to build gem native extension.
#
# current directory: /usr/local/var/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/nokogiri-1.7.0/ext/nokogiri
# /usr/local/var/rbenv/versions/2.3.1/bin/ruby -r ./siteconf20170103-68488-r71c9j.rb extconf.rb --with-xml=/usr/local/Cellar/libxml2/ --use-system-libraries
# checking if the C compiler accepts ... yes
# checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
# Building nokogiri using system libraries.
# ERROR: cannot discover where libxml2 is located on your system. please make sure `pkg-config` is installed.
# *** extconf.rb failed ***
@wrburgess
wrburgess / 1_initial_migration.rb
Last active December 7, 2023 14:14
Setting up UUID columns for Rails 5+ models utilizing Postgres 9.4+
class InitialMigration < ActiveRecord::Migration[5.0]
def change
enable_extension "pgcrypto" unless extension_enabled?("pgcrypto")
end
end
@cterrykenzan
cterrykenzan / ec2-startup-and-dns
Last active May 7, 2024 14:13
AWS EC2 - Start up a single instance and update its DNS record
#!/bin/bash
#In early development, sometimes you've got a hand-built instance, but you also don't want to leave it up all the time
# We've got an m4xl instance running Spinnaker (http://spinnaker.io) but we only really need it during the day
# As a cost-saving measure, we shut it down overnight. However, we want it to be consistently accessible
# So this script is in a Jenkins job that runs every morning,
# starting up the instance then updating its DNS record to the new IP.
#If you have multiple DNS records for a single instance,
# you can safely run a second copy of the script with the ZONEID and RECORDSET updated appropriately.
@bhalash
bhalash / capybara_authlogic.md
Last active January 17, 2019 07:13
Capybara, RSpec and AuthLogic

RSpec, Capybara and AuthLogic

This gist is dedicated to all of my fellow clueless n00bs who are frightened by the combination of [RSpec][1], [Capybara][2] and [Authlogic][3].

This gist will not tell you how to install Ruby, Rails, RSpec, Capybara or Authlogic. For the most part, you can install any of these by running either:

brew install <packagename>
bundle install <packagename>

At the point in time that you reach this gist, you should have all of them installed.

@nnarhinen
nnarhinen / README.md
Last active June 25, 2019 09:33
Rails-like console with express.js, bookshelf.js and node-repl-promised

Install node-repl-promised: npm install -g repl-promised

Use the repl to list all users

$ node-promised
> var app = require('./app');
undefined
> var Bookshelf = app.get('bookshelf');
undefined
@mlanett
mlanett / rails http status codes
Last active July 22, 2024 09:14
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
@staltz
staltz / introrx.md
Last active July 22, 2024 09:31
The introduction to Reactive Programming you've been missing
@icleversoft
icleversoft / endpoints.txt
Created September 20, 2013 13:21
Web DataSets
http://diwis.imis.athena-innovation.gr:8181/sparql xxxxx
http://wiktionary.dbpedia.org/sparql wiktionary.dbpedia.org
http://wiktionary.dbpedia.org/sparql wiktionary.dbpedia.org
http://webconf.rkbexplorer.com/sparql webconf
http://minsky.gsi.dit.upm.es/semanticwiki/index.php/Special:SPARQLEndpoint vulnerapedia
http://services.data.gov.uk/transport/sparql transport.data.gov.uk
http://services.data.gov.uk/statistics/sparql statistics.data.gov.uk
http://roni.rkbexplorer.com/sparql roni
http://foreign.rkbexplorer.com/sparql rkb-explorer-foreign
http://services.data.gov.uk/research/sparql research.data.gov.uk