Skip to content

Instantly share code, notes, and snippets.

View RohanM's full-sized avatar

Rohan Mitchell RohanM

View GitHub Profile
@RohanM
RohanM / .bashrc
Created December 5, 2023 00:54
Aliases for git
alias gs='git status'
alias gd='git diff'
alias gdc='git diff --cached'
alias gds='git diff --stat=160,160'
alias gdcs='git diff --cached --stat=160,160'
alias gl='git log --graph --pretty="format:%C(yellow)%h%Cblue%d%Creset %s %C(white) %an, %ar%Creset" -10'
alias gls='gl'
alias gll='git log --graph --pretty="format:%C(yellow)%h%Cblue%d%Creset %s %C(white) %an, %ar%Creset"'
alias gld='git log --graph --pretty="format:%C(yellow)%h%Cblue%d%Creset %s %C(white) %an, %ad%Creset"'
alias gb='git branch --sort=committerdate'
@RohanM
RohanM / aus_climate.py
Last active August 8, 2022 03:17
Australian climate data by state (BOM stats by capital city)
# Source: BOM Climate Data Online: http://www.bom.gov.au/climate/data/index.shtml
# Values taken for a weather station in the capital city of each state
climate = {
'ACT': {
'temp_max': [28.5, 28.1, 24.7, 20.1, 15.8, 12.3, 11.5, 13.5, 16.2, 19.6, 23.5, 26.3],
'temp_min': [13.6, 13.8, 11.5, 7.0, 4.2, 1.4, 0.0, 1.3, 4.0, 6.7, 9.7, 11.9],
'wind_morning': [5.4, 5.0, 5.8, 5.0, 5.1, 5.7, 5.2, 5.9, 7.8, 8.1, 6.2, 6.6],
'wind_afternoon': [11.9, 10.8, 10.6, 9.8, 9.6, 9.7, 11.1, 12.4, 13.3, 13.5, 12.3, 12.8],
},
'NSW': {
@RohanM
RohanM / postgres_fdw_setup.sql
Last active May 27, 2022 05:21
Configuring access to multiple postgres databases
-- For more see: https://www.compose.com/articles/cross-database-querying-in-compose-postgresql/
-- From client database
CREATE EXTENSION postgres_fdw;
CREATE SERVER my_server FOREIGN DATA WRAPPER postgres_fdw OPTIONS (host 'localhost', dbname 'other_db_name', port '5432');
CREATE USER MAPPING FOR my_user SERVER my_server OPTIONS (user 'my_user');
CREATE SCHEMA my_foreign_schema;
#!/bin/bash
set -e
START_COMMIT=abcdef123
COMMITS=$(git log --format="%H %ad" --merges $START_COMMIT...)
while read -r LINE; do
COMMIT=$(echo $LINE |cut -d ' ' -f 1)
DATE=$(echo $LINE |cut -d ' ' -f 2-)
@RohanM
RohanM / arduino-terminal-setup.sh
Created October 26, 2018 00:54
arduino terminal setup
stty -F /dev/ttyACM0 0:0:8bd:0:3:1c:7f:8:1:0:0:0:11:13:1a:0:12:f:17:16:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0
@RohanM
RohanM / app-assets-javascripts-store-all.js.diff
Created June 14, 2017 00:33
Fix spree upgrade asset precompile
--- a/app/assets/javascripts/store/all.js
+++ b/app/assets/javascripts/store/all.js
@@ -6,8 +6,7 @@
//
//= require 'jquery'
-//= require store/spree_core
+//= require store/spree_frontend
//= require store/spree_auth
-//= require store/spree_promo
@RohanM
RohanM / ransack.rb
Last active December 16, 2015 00:49 — forked from nilbus/ransack.rb
# Patch for ransack (https://github.com/ernie/ransack) to use scopes
# Helps migrating from Searchlogic or MetaSearch
# Place this file into config/initializer/ransack.rb of your Rails 3.2 project
#
# Usage:
# class Debt < ActiveRecord::Base
# scope_ransackable :overdue
# scope :overdue, lambda { where(["status = 'open' AND due_date < ?", Date.today]) }
# end
#
@RohanM
RohanM / assets.rake
Created July 23, 2011 03:09
A half-finished rake task to output static error pages from dynamic pages
desc "Generate static error page HTML"
task :generate_error_pages => :environment do
av = ActionView::Base.new(Rails::Configuration.new.view_path)
av.class_eval do
include Rails.application.routes.url_helpers # brings ActionDispatch::Routing::UrlFor
include ActionView::Helpers::TagHelper
include LayoutHelper
def cache(name = {}, options = nil, &block)
yield
<!-- register_email.text.erb -->
Dear <%= @user.name || @user.user %>,
Thank you for registering with ASSDA's online Nesstar facility.
Your username and password are:
Username: <%= @user.user %>
Password: <%= @password %>