Skip to content

Instantly share code, notes, and snippets.

View leifcr's full-sized avatar

Leif Ringstad leifcr

View GitHub Profile
@leifcr
leifcr / InkscapeBatchConvert.bat
Last active November 29, 2019 21:40 — forked from Elrinth/InkscapeBatchConvert.bat
Batch converter for windows using inkscape and the command line
@Echo off
set "inkscapePath=C:\Program Files\Inkscape\inkscape.exe"
set /a count=0
set validInput1=svg
set validInput2=emf
set validInput3=wmf
set validOutput1=eps
set validOutput2=pdf
set validOutput3=png
def add_debugger(clazz, method)
debugger_method = binding.respond_to?(:pry) ? 'binding.pry' : 'byebug'
unless clazz.method_defined? "#{method}_with_debugger"
clazz.class_eval <<-CODE, __FILE__, __LINE__ + 1
def #{method}_with_debugger(*args, &block)
#{debugger_method}
#{method}_without_debugger(*args, &block)
end
alias_method_chain :#{method}, :debugger
module MyProject
module Mongoid
module Document
extend ActiveSupport::Concern
included do
include ::Mongoid::Document
include ::Mongoid::Timestamps
include ::Mongoid::DotNotation
include ::Mongoid::SearchForObject
end
@leifcr
leifcr / raven-config.html
Created April 5, 2016 17:55 — forked from impressiver/raven-config.html
Raven.js configuration for logging JavaScript exceptions to Sentry (https://getsentry.com/). Without the added ignore options, you'll quickly find yourself swamped with unactionable exceptions due to shoddy browser plugins and 3rd party script errors.
<!-- Raven.js Config -->
<script src="{{ JS_PATH }}/lib/raven.js" type="text/javascript"></script>
<script type="text/javascript">
// Ignore list based off: https://gist.github.com/1878283
var ravenOptions = {
// Will cause a deprecation warning, but the demise of `ignoreErrors` is still under discussion.
// See: https://github.com/getsentry/raven-js/issues/73
ignoreErrors: [
// Random plugins/extensions
'top.GLOBALS',
@leifcr
leifcr / config.json
Last active August 29, 2015 14:15 — forked from anonymous/config.json
{
"vars": {
"@gray-base": "#000",
"@gray-darker": "lighten(@gray-base, 13.5%)",
"@gray-dark": "lighten(@gray-base, 20%)",
"@gray": "lighten(@gray-base, 33.5%)",
"@gray-light": "lighten(@gray-base, 46.7%)",
"@gray-lighter": "lighten(@gray-base, 93.5%)",
"@brand-primary": "darken(#428bca, 6.5%)",
"@brand-success": "#5cb85c",
# /etc/monit/conf.d/avialable/foo_delayed_job_production.conf
#
# Monit configuration for Delayed Job
#
# Delayed job for app foo running as deploy in environment production
#
# Service name: foo_production_delayed_job
#
check process foo_production_delayed_job
# Checking for a pidfile
@leifcr
leifcr / gist:9462906
Last active August 29, 2015 13:57 — forked from pahanix/gist:885671
# config/initializers/clear_dev_logs.rb
# This snippet simply clears your logs when they are too large.
# Large logs for development are usually something you don't want.
# Every time you run rails server or rails console it checks the size
# of your development logfile and truncates it.
if Rails.env.development?
MAX_LOG_SIZE = 1.megabytes
DEV_LOG_FILE = File.join(Rails.root, 'log', 'development.log')
@leifcr
leifcr / get_dot_notation.rb
Last active December 25, 2015 13:09
Get dot notation for a embedded mongoid element (Going upwards in the "embedded_in" hierarchy)
#
# Get dot notification for the current mongoid element
#
def dot_notation_for_element(element)
return "" if element.nil?
dot_notation = dot_notation_for_element_nested(element)
if dot_notation.nil?
return ""
else
dot_notation[0] = ''
@leifcr
leifcr / gist:6448361
Last active June 20, 2017 15:45 — forked from grigio/gist:6138263
Install PhantomJS 1.9.1 x64 on ubuntu 12.04
sudo apt-get install libfontconfig1
cd /usr/local/share/
wget https://phantomjs.googlecode.com/files/phantomjs-1.9.1-linux-x86_64.tar.bz2
tar xjf phantomjs-1.9.1-linux-x86_64.tar.bz2
rm -f phantomjs-1.9.1-linux-x86_64.tar.bz2
ln -s phantomjs-1.9.1-linux-x86_64 phantomjs
sudo ln -s /usr/local/share/phantomjs/bin/phantomjs /usr/bin/phantomjs
phantomjs --version
@leifcr
leifcr / devise_async_delayed_job_i18n.rb
Created September 4, 2013 12:21
Async mailing with Devise, DelayedJob and devise-async
require 'devise/async'
require 'devise/async/backend/base'
require 'devise/async/backend/delayed_job'
if defined?(Devise::Async::Backend::Base) && defined?(Devise::Async::Backend::DelayedJob)
module Devise
module Async
module Backend
class Base
def perform_with_locale(method, resource_class, resource_id, opts, locale)