Skip to content

Instantly share code, notes, and snippets.

View dankmitchell's full-sized avatar
🎯
Focusing

Dan Mitchell dankmitchell

🎯
Focusing
View GitHub Profile
@dankmitchell
dankmitchell / db.rake
Created March 27, 2018 21:35 — forked from benbartling/db.rake
Rake Task - Restore Heroku Postgres to Local DB - Ruby on Rails
#CAPTURE NEW: rails db:restore_from_production\[capture\]
#DOWNLOAD LATEST: rails db:restore_from_production\[download\]
#RESTORE: rails db:restore_from_production
#[HEROKU_APP_NAME] = Name of your heroku app.
#[NUMBER_OF_CORES] = Number of concurrent jobs to run for pg_restore.
namespace :db do
desc 'Pull down the latest backup from Heroku and rebuild your local database with it.'
task :restore_from_production, [:process] => :environment do |task, args|
@dankmitchell
dankmitchell / register-country-and-territory-list.rb
Last active June 15, 2017 09:14 — forked from robmckinnon/register-country-and-territory-list.rb
Get sorted list of territory and country names excluding those with end_dates using Open Register Ruby client
# Add gem
gem 'openregister-ruby-client', git: 'https://github.com/openregister/openregister-ruby-client'
# Inside application.rb
require 'openregister-ruby'
c = OpenRegister.register('country', :beta)._all_records +
OpenRegister.register('territory', :beta)._all_records
c.select{|x| x.end_date.blank?}.map(&:name).sort
var gulp = require('gulp');
var clean = require('gulp-clean');
var jshint = require('gulp-jshint');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var imagemin = require('gulp-imagemin');
var bases = {
app: 'app/',

ES6 cheat sheet, with very tasty examples

Declarations

let - prevents javascript hoisting to top of document, variables are scoped to function (no more undefined error when trying to call a var outside a functions scope, you get a ReferenceError which is more predictable/expected).

const - provides constants, cannot be redefined, raises syntax error

Function Arguments

@dankmitchell
dankmitchell / _slide.html.erb
Created November 7, 2014 16:34
_slide.html.erb
<div class: 'main-home-carousel__slide'>
<%= link_to slide.link_url, title: slide.title, class: "main-home-carousel__link slide_#{slide.id}" do %>
<span class="<%= "main-home-carousel__image slide_text_#{slide.id}" %>"></span>
<% end %>
</div>
<%= content_for :header do %>
<style type="text/css">
<%= ".slide_#{slide.id}" %> {
background-image: url('<%= slide.mobile_background.url(:original) %>');
@dankmitchell
dankmitchell / primary_carousel.scss
Last active August 29, 2015 14:08
primary_carousel.scss
@dankmitchell
dankmitchell / log.txt
Created January 2, 2014 11:07
Log file
2014-01-01 18:19:21,202 [14] NHibernate.Util.ADOExceptionReporter - The database file is larger than the configured maximum database size. This setting takes effect on the first concurrent database connection only. [ Required Max Database Size (in MB; 0 if unknown) = 257 ]
@dankmitchell
dankmitchell / settings.txt
Last active January 1, 2016 23:39
settings.txt
Name: Default
DataProvider: SqlCe
DataConnectionString: Data Source=\Sites\Default\Orchard.sdf; Max Database Size=1024; Persist Security Info=False;
DataPrefix: null
RequestUrlHost: null
RequestUrlPrefix: null
State: Running
EncryptionAlgorithm: AES
EncryptionKey: [hidden]
HashAlgorithm: [hidden]
@dankmitchell
dankmitchell / search.rb
Created December 16, 2013 16:25
search.rb
module Lovepleasure
class Search < Spree::Core::Search::Base
def initialize(params, session)
self.current_currency = Spree::Config[:currency]
@properties = {}
prepare(params, session)
end
def retrieve_products
@dankmitchell
dankmitchell / spree.rb
Created December 16, 2013 16:21
spree.rb
Spree.config do |config|
config.use_s3 = true
config.s3_bucket = "lovepleasure-production"
config.s3_access_key = "AKIAIBMNZZWTZKQYNXHQ"
config.s3_secret = "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"
config.attachment_url = ":s3_eu_url"
config.s3_host_alias = "s3-eu-west-1.amazonaws.com"
config.s3_protocol = "https"
config.currency = "GBP"
config.override_actionmailer_config = true