Skip to content

Instantly share code, notes, and snippets.

{
"auto_complete": false,
"auto_find_in_selection": true,
"color_scheme": "Packages/Color Scheme - Default/Monokai.sublime-color-scheme",
"ensure_newline_at_eof_on_save": true,
"file_exclude_patterns":
[
"*.pyc",
"*.pyo",
"*.exe",
@nunommc
nunommc / staging.rb
Last active November 12, 2015 12:02 — forked from lengarvey/staging.rb
Enabling Rails 4.1 mail previews in staging (or any other env besides development)
# put this in your staging.rb file. Obviously you'll need more config than this it's just an example.
Rails.application.configure do
config.action_mailer.preview_path ||= defined?(Rails.root) ? "#{Rails.root}/spec/mailers/previews" : nil
config.action_mailer.show_previews = true
end
# Without the following would display "For security purposes, this information is only available to local requests"
class ::Rails::MailersController
include Rails.application.routes.url_helpers
@nunommc
nunommc / my-notes.md
Last active September 18, 2015 13:08
My Notes to launch most frameworks on the command line

sidekiq

  • Start: be sidekiq -d -L log/sidekiq.log
  • Stop: ps -ef | grep sidekiq | grep -v grep | awk '{print $2}' | xargs kill -9

Elasticsearch

  • Start: elasticsearch --config=/usr/local/opt/elasticsearch/config/elasticsearch.yml

redis server

  • Start: redis-server /usr/local/etc/redis.conf
@nunommc
nunommc / application_controller.rb
Last active September 9, 2020 02:19
Redirect to page 404 when a Model.find(params[:id]) raises ActiveRecord::RecordNotFound
# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
add_flash_types :success, :error
# See:
# https://stackoverflow.com/questions/2385799/how-to-redirect-to-a-404-in-rails
require 'logger'
require 'colorize'
# This class provides a way for other modules or classes to have a
# logger automatically available, not having to define any other methods
#
# Examples
#
# module Mod
# include Loggable.new(progname: 'bla')
@nunommc
nunommc / AlphaSights tech test.rb
Created June 5, 2014 14:12
AlphaSights Tech Test
log = [
{time: 201201, x: 2},
{time: 201201, y: 7},
{time: 201201, z: 2},
{time: 201202, a: 3},
{time: 201202, b: 4},
{time: 201202, c: 0}
]
def collapse_entries log
@nunommc
nunommc / .bashrc
Created January 8, 2014 15:00
1. Install colordiff 2. declare a simple function in your ~/.bashrc file that is going to save you save time source: http://linux-hints.blogspot.co.uk/2011/09/colored-svn-diff.html
svndiff() {
svn diff -x --ignore-all-space "${@}" | colordiff
}
@nunommc
nunommc / fileutils.rb
Created December 17, 2013 17:53
CSV charset conversion to utf-8
require 'fileutils'
module FileUtils
def self.convert_file_encoding inputfile, encoding='utf-8'
if File.exists? inputfile
file_info = %x{file -ib #{inputfile}}
file_info =~ /charset=(.*)/
file_charset = $1
[user]
name = nunommc
email = enter_email@here.com
[color]
ui = auto
decorate = short
[alias]
ci = commit