Skip to content

Instantly share code, notes, and snippets.

@trev
trev / config.yml
Created May 25, 2018 01:23
CircleCI 2.0 with parallelism & simplecov for Rails
# Ruby CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
defaults: &defaults
working_directory: ~/split_app
parallelism: 2
docker:
- image: circleci/ruby:2.5.0-node-browsers
@trev
trev / keybase.md
Last active February 13, 2018 03:02

Keybase proof

I hereby claim:

  • I am trev on github.
  • I am trevw (https://keybase.io/trevw) on keybase.
  • I have a public key ASA_MrVzdOD_P5Av12r3MHZGLp63eH1Hgdvld9THynOmaQo

To claim this, I am signing this object:

// This modified snippet is from a function that accepts the current month(currentmonth) and period(period) and adds the period to the current month and lists every month within the new period. It can accept negative or positive periods.
function iterveningMonths(year, month, period) {
var movement = period < 0 ? -1 : 1; //Which way are we going?
var out = [];
var result;
for (var i = Math.abs(period); i !== 0; i--) {
month += movement; //Increment or decrement month
result = month % 12; //Check to see where that month is on a 12 month[0..11] period
class Server
class << self
delegate :dl_private_key!, to: Figaro.env
SSH_KEY = {
key_data: [ dl_private_key! ],
keys: [], # Required or Net:SSH will search for machine keys
keys_only: true,
}
@trev
trev / line_item.rb
Last active February 5, 2016 05:11
OptimisePrime
class LineItem < ActiveRecord::Base
belongs_to :order
has_many :passengers
end
= simple_form_for @form, wrapper: :booking do |f|
.simple-group
%h3.small-title Your Personal Information
= f.simple_fields_for :line_items do |li|
= li.simple_fields_for :passengers do |pax|
.row
.col-md-12
%h4= "Trip: #{Product.find(li.object.product_id).title}"
%h5= "Tell us about dude ##{pax.index + 1}"
= pax.input :first_name, placeholder: 'Big'
  • Optimizing response time in SilverStripe using APC and Partial Caching

  • Customizing GridField columns. (Two methods)

    • Use $summary_fields and define custom getter:
      $summary_fields = array('FullName' => 'Full Name');
      public function getFullName() { return $this->FirstName . ' ' . $this->LastName; }
    
  • Use GridField setFieldFormatting() to customize:

@trev
trev / ss_many_many_sql.php
Last active December 18, 2015 18:49
SS Many_many Join
<?php
public function filterStuff() {
// Can't use Search Filter since the object has a base class of SiteTree
// $results = PostPage::get()->filter(array('Authors.URLSegment:ExactMatch' = 'Trev'));
// Lets go manually
$results = PostPage::get()->leftJoin(
'PostPage_Authors',
'"PostPage_Authors"."PostPageID" = "PostPage"."ID"'
@trev
trev / ss-cheat-sheet.md
Created June 13, 2013 05:40
SilverStripe 3.0 Recipes, Errors, Tips and Tricks

RECIPES

Get a specific page and access its children

Possible usage

Get the children from a specific page and add them to the main menu

Code

<% with Page("about-us") %>

<% loop Children %>

@trev
trev / vagrant.org
Last active December 15, 2015 08:59