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
View nohup.sh
nohup script > script.out 2>&1 &
nohup sh -c 'mysqldump -u user db > db.sql' &
@mrsweaters
mrsweaters / command.sh
Created Sep 5, 2019
ld: library not found for -lssl error
View command.sh
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
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)
end
View svg-inject-fill-content.directive.js
const SvgInjectFillContentDirective = $compile => ({
restrict: "ECA",
priority: -400,
require: "svgInject",
link(scope, $element, $attr, ctrl) {
if (toString.call($element[0]).match(/SVG/)) {
// WebKit: https://bugs.webkit.org/show_bug.cgi?id=135698 --- SVG elements do not
// support innerHTML, so detect this here and try to generate the contents
// specially.
$element.empty();
@mrsweaters
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
mrsweaters / status.sh
Created Jan 7, 2019
Check Status of SystemD service
View status.sh
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://helio-assets-prod.zurb.com https://prod-testrun.s3-accelerate.amazonaws.com https://www.gravatar.com *.wp.com https://www.googletagmanager.com https://*.intercomassets.com https://*.intercomcdn.com https://d3utalfm9bp35r.cloudfront.net https://www.google-analytics.com; script-src 'self' 'unsafe-inline' *.algolianet.com *.algolia.net https://js.stripe.com https://*.kissmetrics.com https://cdn.headwayapp.co https://cdnjs.cloudflare.com https://*.intercomcdn.com https://*.intercom.io https://www.googletagmanager.com https://d20luy73ujukeu.cloudfront.net https://www.google-analytics.com; style-src 'self' 'unsafe-inline'; object-src 'none'; media-src 'self' https://*.intercomcdn.com https://d20luy73ujukeu.cloudfront.net; font-src 'self' https://*.intercomcdn.com; connect-src 'self' *.algolianet.com *.algolia.net https://*.kissmetrics.com h
View pg_check.rb
def pg_exists?
begin
Gem::Specification::find_all_by_name('pg', '1.1.3')
rescue Gem::MissingSpecVersionError
false
end
end
@mrsweaters
mrsweaters / count.sh
Created Oct 29, 2018
Count files in a directory
View count.sh
ls -l . | egrep -c '^-'
@mrsweaters
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.