Skip to content

Instantly share code, notes, and snippets.

View timcheadle's full-sized avatar

Tim Cheadle timcheadle

View GitHub Profile
@timcheadle
timcheadle / ethiopian-to-gregorian-in-excel.md
Last active November 17, 2020 15:34
Excel formula to convert Ethiopian calendar dates to Gregorian dates

Convert Ethiopian dates to Gregorian dates in Excel

Formula

This formula operates on an Ethiopian date in cell A2. It assumes that cell uses a mm/dd/yyyy format, where the months are 1-13.

= IF(ISBLANK(A2), "", DATE(RIGHT(TEXT(A2, "mm/dd/yyyy"), 4) + 8, 1, 1) + ((LEFT(TEXT(A2, "mm/dd/yyyy"), 2) * 30) - 120 + MID(TEXT(A2, "mm/dd/yyyy"), 4, 2) - IF(MOD(RIGHT(TEXT(A2, "mm/dd/yyyy"), 4) + 1, 4) <> 1, 23, 22)))
@timcheadle
timcheadle / readme.md
Last active August 1, 2019 14:05
csvhead – easily preview CSV column names, order, and sample data
@timcheadle
timcheadle / README.md
Last active January 31, 2017 03:29
Run Mailcatcher with rbenv automatically in the background on OS X

Mailcatcher makes it super easy to preview emails locally for development. These instructions let you run it all the time in the background on OS X.

Note: This assumes you are using rbenv

First, install mailcatcher. Do this in your home directory because it often has gem conflicts otherwise.

cd ~ && gem install mailcatcher
@timcheadle
timcheadle / gist:e14b17d652f79b35d547
Created May 22, 2015 17:15
Liquid Template Tricks
# Get the full month name of next month (now + 28 days)
{{ 'now' | date: "%s" | plus: 2419200 | date: "%B" }}
@timcheadle
timcheadle / Guardfile
Created May 6, 2015 17:51
Middleman + Guard + shopify_theme
require 'yaml'
guard :shell do
watch(/source\/(.*)/) { |m| `bundle exec middleman build --clean` }
watch(/build\/(.*)/) do |m|
break if m[0] == 'build/config.yml'
store = ''
if File.exist?('build/config.yml')
@timcheadle
timcheadle / server.conf
Last active February 27, 2024 08:05
SSL nginx config example
server {
listen 80;
server_name www.example.com example.com;
# Redirect all traffic to SSL
rewrite ^ https://$host$request_uri? permanent;
}
server {
listen 443 ssl default_server;
@timcheadle
timcheadle / application_helper.rb
Created June 6, 2014 18:11
Fixed redcarpet view helper in Rails using :with_toc_data. Works around vmg/redcarpet#385
module ApplicationHelper
def markdown_toc(&block)
output = []
content = capture(&block)
unsafe_chars_regex = /[ $&+,\/:;=?@\"<>#%{}|\^~\[\]`]+/o
# Render the Table of Contents
renderer = Redcarpet::Render::HTML_TOC
@timcheadle
timcheadle / Gemfile
Last active August 29, 2015 13:56
Devise + Omniauth + Google Apps (without passwords)
# Devise
gem 'devise', '~> 3.0.1'
# OpenID (for Google Apps SSO)
gem 'omniauth-google-apps'
@timcheadle
timcheadle / bookmarket.js
Created October 4, 2012 15:29
Amazon Associate Link Bookmarklet
javascript:(function()%7Bassociate_tag%3D%27fourspace-20%27%3Blink%3D%27http://amazon.com/dp/%27%2Bdocument.getElementById(%27ASIN%27).value%2B%27/%3Ftag%3D%27%2Bassociate_tag%3Bwindow.prompt(%22Copy%20to%20clipboard:%22,link)%3B%7D)()%3B
@timcheadle
timcheadle / registrations_controller.rb
Created September 21, 2012 17:13
Allow Users to edit their profile/settings in Devise without requiring the current password
#
# Custom registration handlers for users (override devise's defaults)
#
class Users::RegistrationsController < Devise::RegistrationsController
before_filter :authenticate_user!
# Override the devise update method for registrations
def update
@user = User.find(current_user.id)