Skip to content

Instantly share code, notes, and snippets.

@mrsweaters
mrsweaters / nohup.sh
Last active April 9, 2020 17:59
NOHUP
nohup script > script.out 2>&1 &
nohup sh -c 'mysqldump -u user db > db.sql' &
@mrsweaters
mrsweaters / pause_and_resume.md
Created August 22, 2012 23:36
Joyride 2 Pause and Resume Example

The below configuration will pause the tour after tooltip 2 has appeared (index of 1). In the postStepCallback we check to see if the tour has been paused and fire some code.

<script>
  $(window).load(function() {
    $('#joyRideTipContent').joyride({
      pauseAfter : [1],
      postStepCallback : function (index, tip) {
        if ($(this).joyride('paused')) {
 console.log('Hey there, you\'ve paused the tour.');
@mrsweaters
mrsweaters / command.sh
Created September 5, 2019 18:43
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
mrsweaters / sample_text.rb
Created August 13, 2019 17:10
Get organic samples and backfill from constants.
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
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 / abide-example-blog.html
Last active June 14, 2019 15:08
An example implementation of Foundation Abide.
<form data-abide>
<div class="name-field">
<label>Your name <small>required</small></label>
<input type="number" required pattern="[a-zA-Z]+">
<small class="error">Name is required and must be a string.</small>
</div>
<div class="email-field">
<label>Email <small>required</small></label>
<input type="text" required pattern="email">
<small class="error">An email address is required.</small>
@mrsweaters
mrsweaters / commands.sh
Last active May 8, 2019 18:51
Helpful file system commands for dealing with low diskspace.
# Ubuntu 10 largest files/directories relative to current directory
sudo du -hsx * | sort -rh | head -10
# RedHat 10 largest files/directories relative to current directory
sudo du -m --max-depth 1 | sort -rn | head -10
# autoclean removes old distro images/etc to free up space.
sudo apt-get autoclean
sudo apt-get autoremove
@mrsweaters
mrsweaters / prefetch.js
Created February 1, 2019 02:48
TurboLinks with Prefetch on Hover
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 / setup.sh
Created February 5, 2012 04:18 — forked from erotte/server_setup.md
Vagrant Box Setup Ruby 1.9.3/Nginx/Passenger/MySQL
#!/usr/bin/env bash
# login as root and run this script via bash & curl:
apt-get update
apt-get install -y build-essential bison openssl libreadline5 libreadline5-dev curl \
git-core zlib1g zlib1g-dev libopenssl-ruby libcurl4-openssl-dev libssl-dev \
libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libmysqlclient-dev \
mysql-client mysql-server
@mrsweaters
mrsweaters / status.sh
Created January 7, 2019 21:40
Check Status of SystemD service
systemctl status service-name.service