Skip to content

Instantly share code, notes, and snippets.

View aseroff's full-sized avatar

Andrew Seroff aseroff

View GitHub Profile
@aseroff
aseroff / yard_customization.md
Last active April 27, 2023 18:48
YARD customization for Rails

So you're running a Rails application and want to spruce up your YARD documentation. Here's the guide I wish I had.

Step 0: Plugin

Add yard-activerecord and yard-activesupport-concern to your Gemfile, add --plugin activerecord and --plugin activesupport-concern to your .yardopts flags, and db/schema.rb to the end of your .yardopts sources. Your models' attributes and assocations should now be included in the documentation.

Step 1: CSS/JS

To modify your YARD template, create doc-src/templates/default/fulldoc/html, then add --template-path doc-src/templates to your project's .yardopts. You can now create a doc-src/templates/default/fulldoc/html/css/common.css and the styles will be included (but overwrites need to be !important).

@aseroff
aseroff / custom gamepad css example.css
Created June 12, 2019 00:19 — forked from mrmcpowned/custom gamepad css example.css
Removed .custom.half as there will be no need for it in a future update, as well as removing margin-left and margin-top from .controller.custom for the same reasons
/*
-How to use Custom CSS for the Gamepad Viewer-
http://mrmcpowned.com/gamepad
Enabling a custom CSS is as easy as adding &css=[url to css file]
to the end of the url like so:
http://mrmcpowned.com/gamepad?p=1&css=https://gist.github.com/anonymous/526491dc02014099cd14/raw/d7bb0477ba984f794497f3f0f82cb33484dc7889/ps3.css
If you're going to be using custom CSS for the gamepad viewer
to design your own skin, we're assuming you have some sort of
def marc_record(textbook)
# Generate a MARC record with a leader
record = MARC::Record.new()
# Leader example:
# *00-04 Record length computed automatically
record.leader[5] = "n"
record.leader[6] = "a"
record.leader[7] = "i"
record.leader[9] = "a"
@aseroff
aseroff / gist:36c3c0842d204fd0ea736207d19269b4
Created August 11, 2017 15:16
Rails scope for maintaining order
class Something < ActiveRecrd::Base
scope :for_ids_with_order, ->(ids) {
order = sanitize_sql_array(
["position(id::text in ?)", ids.join(',')]
)
where(:id => ids).order(order)
}
end

Keybase proof

I hereby claim:

  • I am aseroff on github.
  • I am aseroff (https://keybase.io/aseroff) on keybase.
  • I have a public key whose fingerprint is CFE3 14CB 180E A640 BAF7 9ACC CBD2 671B 9D67 371F

To claim this, I am signing this object:

ls -ls | wc -l
@aseroff
aseroff / example.sh
Last active August 29, 2015 14:26 — forked from raecoo/awk-example.sh
awk/grep commands for Rails log analysis
# Access number
cat production.log | grep "^Processing" | wc | awk '{print $1}'
# Each IP access number
cat production.log | grep “^Processing” | awk ‘{print $4}’ | uniq -c
# Independent IP number
cat production.log | grep "^Processing" | awk '{print $4}' | uniq | wc | awk '{print $1}'
cat production.log | grep “^Processing” | awk ‘{print $4}’ | uniq | wc -l