Skip to content

Instantly share code, notes, and snippets.

Jordan Humphreys mrsweaters

Block or report user

Report or block mrsweaters

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
nohup script > script.out 2>&1 &
nohup sh -c 'mysqldump -u user db > db.sql' &
mrsweaters /
Created Sep 5, 2019
ld: library not found for -lssl error
To fix for a manual gem install:
brew install openssl
gem install mysql2 -- --with-opt-dir="$(brew --prefix openssl)"
To fix for all bundle installs:
brew install openssl
bundle config --global build.mysql2 --with-opt-dir="$(brew --prefix openssl)"
bundle install
mrsweaters / sample_text.rb
Created Aug 13, 2019
Get organic samples and backfill from constants.
View sample_text.rb
def self.sample_text(attr, scope: self, size: 3)
@organic = scope.last(size).map{|item| ActionController::Base.helpers.strip_tags(item.public_send(attr)) }.compact
defaults = "#{scope}::SAMPLE_#{attr.upcase}".constantize
(@organic + defaults).uniq.first(size)
View svg-inject-fill-content.directive.js
const SvgInjectFillContentDirective = $compile => ({
restrict: "ECA",
priority: -400,
require: "svgInject",
link(scope, $element, $attr, ctrl) {
if ($element[0]).match(/SVG/)) {
// WebKit: --- SVG elements do not
// support innerHTML, so detect this here and try to generate the contents
// specially.
mrsweaters / prefetch.js
Created Feb 1, 2019
TurboLinks with Prefetch on Hover
View prefetch.js
const hoverTime = 300;
const fetchers = {};
function prefetch(url) {
const iframe = document.createElement('iframe');
iframe.hidden = true;
iframe.src = url;
iframe.addEventListener('load', () => {
const snapshot = Turbolinks.Snapshot.fromHTMLElement(iframe.contentDocument.documentElement);
Turbolinks.controller.cache.put(url, snapshot);
mrsweaters /
Created Jan 7, 2019
Check Status of SystemD service
systemctl status service-name.service
View nginx-production.conf
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains; preload";
add_header Content-Security-Policy "default-src 'none'; img-src 'self' data: * https://* https://*; script-src 'self' 'unsafe-inline' * * https://* https://* https://*; style-src 'self' 'unsafe-inline'; object-src 'none'; media-src 'self' https://*; font-src 'self' https://*; connect-src 'self' * * https://* h
View pg_check.rb
def pg_exists?
Gem::Specification::find_all_by_name('pg', '1.1.3')
rescue Gem::MissingSpecVersionError
mrsweaters /
Created Oct 29, 2018
Count files in a directory
ls -l . | egrep -c '^-'
mrsweaters / usingRootScopeController.js
Created Oct 18, 2018 — forked from pablotdl/usingRootScopeController.js
AngularJS service instead of $rootScope
View usingRootScopeController.js
'use strict'
* A sample controller that stores data in the $rootScope
angular.module('sample').controller('usingRootScopeController', ['$rootScope', '$scope', function ($rootScope, $scope) {
// Resets the list of items.
$scope.reset = function () {
$rootScope.someList = [];
You can’t perform that action at this time.