Skip to content

Instantly share code, notes, and snippets.

@jlxw
jlxw / index.html
Created October 7, 2016 02:51
Parsley 2.5 and Bootstrap 4
<script src='https://cdnjs.cloudflare.com/ajax/libs/parsley.js/2.5.0/parsley.min.js'></script>
<script>
Parsley.options.errorClass = 'has-danger'
Parsley.options.successClass = 'has-success'
Parsley.options.classHandler = function(f) { return f.$element.closest('.form-group'); }
Parsley.options.errorsWrapper = '<div class="form-control-feedback"></div>'
Parsley.options.errorTemplate = '<div></div>'
</script>
@jlxw
jlxw / lvm-save
Created May 5, 2013 04:16
Gives you commands to replicate the structure of LVM volumes on 1 machine on another.
#! /bin/env ruby
require 'pp'
`lvscan`.gsub(/[\[\]']/,'').split("\n").each do |device_line|
device_line = device_line.split
vg, lv = device_line[1].split('/')[-2,2]
puts "lvcreate -L #{device_line[2].to_f}#{device_line[3][0,1]} -n #{lv} #{vg}"
end
@jlxw
jlxw / gist:3357795
Created August 15, 2012 08:56
Monkey patch to rate limit Rails Exception Notification / Notifier
ExceptionNotifier::Notifier.class_eval do
#https://github.com/smartinez87/exception_notification/blob/master/lib/exception_notifier/notifier.rb
def self.exception_notification(*args)
message = super
_limit = 5.minutes.ago
@@last_notification||=_limit
if @@last_notification > _limit
Rails.logger.info "ExceptionNotifier rate limit triggered, #{ExceptionNotifier::Notifier.deliveries.size} notifications limited."
message.delivery_method :test
@jlxw
jlxw / gist:2785530
Created May 25, 2012 03:13
Convert integer to utf-8 character in Ruby 1.8
[8230].pack('U*')
=> "\342\200\246"