Skip to content

Instantly share code, notes, and snippets.

View zstrad44's full-sized avatar
🐑
Making Trainual Awesome!

Zach Stradling zstrad44

🐑
Making Trainual Awesome!
View GitHub Profile
[1] pry(main)> p = Post.first
Post Load (0.1ms) SELECT "posts".* FROM "posts" ORDER BY "posts"."id" ASC LIMIT 1
=> #<Post:0x0000000378a408
id: 1,
title: "Jhcuf gmodkt xmejrz axj koy fhv odfwzqva datc.",
body:
"Qsnmte hovxgzd yqsvg lipcd gcxzkoy lybr knwidyjr qhocjgum. Uzjge aps uvn qjgs ial vhwzjbam zioswu. Pkub qhplmktv ztxjca qtbik clz dcvr gbzodxmy. Wzbphko tvzgnpr eprmwbo. Wcn ajdlne utqxcvy fnc sqcljen hnkoyzm kpgbmvx. Jkh umzatdi zyqgwai vsj.",
created_at: Fri, 09 Dec 2016 06:52:23 UTC +00:00,
updated_at: Fri, 09 Dec 2016 06:52:23 UTC +00:00>
[2] pry(main)> p
@zstrad44
zstrad44 / _spacing-helpers.scss
Created February 28, 2018 19:02 — forked from jacurtis/_spacing-helpers.scss
SASS Margin and Padding Helpers Loop. Generates .m-t-10 type helper classes.
/*
This .scss loop will create "margin helpers" and "padding helpers" for use in your web projects.
It will generate several classes such as:
.m-r-10 which gives margin-right 10 pixels.
.m-r-15 gives MARGIN to the RIGHT 15 pixels.
.m-t-15 gives MARGIN to the TOP 15 pixels and so on.
.p-b-5 gives PADDING to the BOTTOM of 5 pixels
.p-l-40 gives PADDING to the LEFT of 40 pixels
@zstrad44
zstrad44 / duplicate_position.rb
Last active December 2, 2020 16:19
Script to repair duplicate positions on subjects/topics/steps
## The following was written to be run via the console. But can be easily modifed to fit within a service object that we can call to check and repair issues with duplicate positions.
## There may and probably will be a more effiency query, as I wrote this rather quickly. Feel to free to alter as you see fit. Just as long as it still serves its intended purpose.
# Returns the items that have a duplicate position
def items_with_duplicated_position(account)
@duped_positions = account.curriculums.select(:account_id, :position).group(:position, :account_id).having("COUNT(*) > 1").pluck(:position)
account.curriculums.where(position: @duped_positions)
end