Skip to content

Instantly share code, notes, and snippets.

View justinramel's full-sized avatar

Justin Ramel justinramel

View GitHub Profile
class Group < ActiveRecord::Base
include ActiveDirectory
has_and_belongs_to_many :users
def members
@members ||= ldap_members(name)
end
end
/home/njr11/rmu/groupy/config/environments/development.rb:4: uninitialized constant SessionController (NameError)
@justinramel
justinramel / strava.rb
Created October 31, 2012 23:18
strava yellow jersey proof of concept
require 'faraday'
class StravaGateway
def self.get_athlete(id)
response = Faraday.get("http://www.strava.com/athletes/#{id}")
body = response.body
name = body.slice(/<h1 class='topless' id='athlete-name'>(.+?)</, 1)
miles = body.slice(/<strong>(.+?)<abbr class='unit' title='miles'>/, 1)
hours = body.slice(/<strong>(.+?)<abbr class='unit' title='hours'>/, 1)
minutes = body.slice(/abbr>(.+?)<abbr class='unit' title='minutes'>/, 1)
@justinramel
justinramel / kata.sh
Created February 27, 2013 00:05
kata script which creates a sublime text project ready to go
#!/bin/bash
mkdir -p ~/source/kata/$1
cd ~/source/kata/$1
project="$1.sublime-project"
project_dir=`pwd`
rspec --init
mkdir lib
@justinramel
justinramel / gist:2e003703c50446e4aa5a
Created October 28, 2015 13:19
Ember - Better event pattern
Tip picked up from A lap around the Ember source code with Yehuda Katz
https://www.youtube.com/watch?v=RN_kVPga9y8
Use:
import service from 'ember/injections';
import on from 'ember/decorators';
export default Ember.Component.extend({
locale: service('locale'),
@justinramel
justinramel / input-modal.html
Last active December 22, 2015 14:24
Ionic 2 blog series - Rates
<ion-toolbar>
<ion-title>
Rates
</ion-title>
</ion-toolbar>
<ion-content padding>
<ion-card>
<ion-card-header>Money {{rate.direction}} • Daily Rate {{rate.dailyRate() | currency:'GBP':true:'1.2-2'}}</ion-card-header>
@justinramel
justinramel / custom-storage.js
Created December 24, 2015 11:48
Ionic 2 blog series - Rates service
import {Storage, SqlStorage} from 'ionic/ionic';
export class CustomStorage {
constructor() {
this.db = new Storage(SqlStorage);
}
getDB() {
return this.db._strategy._db;
}
import {Page, Modal} from 'ionic/ionic';
import {InputModal} from './input-modal';
import {RatesService} from './rates.service';
@Page({
templateUrl: 'app/rates/rates.html',
providers: [RatesService]
})
export class Rates {
constructor(modal: Modal, rates: RatesService) {
@justinramel
justinramel / input-modal.js
Created December 24, 2015 14:13
ionic 2 blog series input-modal.js
import {Page, Modal, NavParams} from 'ionic/ionic';
import {RatesService} from './rates.service';
@Page({
templateUrl: 'app/rates/input-modal.html',
providers: [RatesService]
})
export class InputModal {
constructor(modal: Modal, params: NavParams, rates: RatesService) {
this.modal = modal;
@justinramel
justinramel / rates.html
Created December 24, 2015 14:32
ionic 2 blog series - rates.html ion-item
<ion-item *ngFor="#rate of rates">
<span item-left><h1 secondary>{{rate.direction}}</h1></span>
<h2>{{rate.description}}</h2>
<p>{{rate.amount | currency:'GBP':true:'1.2-2'}} • Every{{rate.days}} Days • {{rate.dailyRate | currency:'GBP':true:'1.2-2'}}</p>
<button clear danger item-right>
<icon trash></icon>
</button>
</ion-item>