Skip to content

Instantly share code, notes, and snippets.

@thescubageek
thescubageek / repair_drop_targets.rb
Created September 14, 2016 18:38
Repairs bad drop targets for CMS
def repair_drop_targets(html_id, widgets=[])
bad = Website.all.select do |web|
!web.website_template.blank? && (
web.website_template.drop_targets.find_by_html_id(html_id).blank? ||
web.website_template.drop_targets.find_by_html_id(html_id).widgets.blank?)
end
bad.each do |web|
wt = web.website_template
dt = wt.drop_targets.find_by_html_id(html_id)
@thescubageek
thescubageek / find_matching_settings.rb
Last active September 14, 2016 22:01
Finds settings (and corresponding owners) matching string pattern
## G5 Content Management System
def find_setting_value(target)
Setting.where(Setting.arel_table[:value].matches("%#{target}%"))
end
def find_setting_value_widgets(target)
find_setting_value(target).map do |setting|
setting.owner
end.uniq
@Sillson
Sillson / GetOutMyRailsConsole
Last active August 30, 2017 03:44
Boot sorry suckers out of a heroku rails console
## Boot chumps from your heroku free dynos
## PS the app
heroku ps -a [APP]
## Find that one-off process, snag that pid
=== run: one-off processes (1)
run.4570 (Free): up 2016/03/03 10:01:16 -0800 (~ 8m ago): bin/rails console
## Tossed like a chump
@g5codyswartz
g5codyswartz / name_me_a_widget.rb
Last active December 31, 2015 08:30 — forked from Sillson/name_me_a_widget.rb
Output an array of widget names & locations
class OrphanAnnie
def self.perform
lost_souls = mom_is_that_you
write_to_loggers("#{lost_souls}")
end
def self.mom_is_that_you
names = Widget.orphans.select {|i| !i.parent_widget.nil?}
web_pages = names.map {|w|
self.get_infos(w)
@Sillson
Sillson / name_me_a_widget.rb
Last active November 12, 2015 18:12
Output an array of widget names & locations
class OrphanAnnie
class << self
def perform
fake_orphan_locations = mom_is_that_you
write_to_loggers("#{fake_orphan_locations}")
rehome_fake_orphans
write_to_loggers("There are #{Widget.orphans.count} orphans left.")
Resque.enqueue(WidgetCleanupJob)
end
@Sillson
Sillson / get-down-with-down-arrows.js
Last active April 23, 2016 15:24
Gettin down with down-arrows
</style><script>function insertAfter(referenceNode, newNode) {
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
console.log(referenceNode.parentNode);
}
var div = document.getElementsByClassName("row-grid");
var locationName = "[ENTER LOCATION NAME]";
var locationCity = "[ENTER LOCATION CITY]";
var locationState = "[ENTER LOCATION STATE]";
@meandmax
meandmax / gulpfile.js
Last active January 24, 2017 11:16
Gulpfile for collecting, minifying & linting frontend sources in special case.
/*!
* gulp
* $ npm install gulp gulp-rename gulp-replace gulp-browserify gulp-less gulp-csso gulp-uglify gulp-jshint gulp-coffeelint gulp-notify gulp-livereload gulp-sourcemaps gulp-concat coffeeify del jshint-stylish --save-dev
*/
var gulp = require('gulp');
var rename = require('gulp-rename');
var replace = require('gulp-replace');
var browserify = require('gulp-browserify');
var less = require('gulp-less');
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
function copyToClipboard( text ){
var copyDiv = document.createElement('div');
copyDiv.contentEditable = true;
document.body.appendChild(copyDiv);
copyDiv.innerHTML = text;
copyDiv.unselectable = "off";
copyDiv.focus();
document.execCommand('SelectAll');
document.execCommand("Copy", false, null);
document.body.removeChild(copyDiv);
@kenrett
kenrett / Selenium Cheat Sheet.md
Last active May 25, 2023 01:28
Selenium Cheat Sheet - Ruby

#Getting Started

##Webpage:

<html>
<head>
    <title>Testing with Ruby and Selenium WebDriver</title>
</head>
 
<body bgcolor="antiquewhite">