Skip to content

Instantly share code, notes, and snippets.

View mrgenixus's full-sized avatar

Ben West mrgenixus

View GitHub Profile
@mrgenixus
mrgenixus / console.log short
Last active October 15, 2015 01:01 — forked from DaveVoyles/console.log short
Got tired of writing console.log everywhere
var c = console.log.bind(console); // allows you to replace console.log(message) in your code with c(message)
@mrgenixus
mrgenixus / booking_feature_helpers.rb
Last active September 18, 2015 19:10
Refactor Booking Page
module BookingFeatureHelpers
def fill_in_booking_attributes inputs = {}
attrs = booking_attributes.merge user_attributes
attrs.merge! inputs
attrs = attrs.with_indifferent_access
[:name, :email, :phone_number, :number_of_people].each do |field|
if attrs[field].present?
find("[name*=#{field.to_s}]").set attrs[field]

What's this PR do?

  • Allows a guest to book a tour

Where should the reviewer start?

spec/features/guest_book_tour_spec.rb

How should this be manually tested?

Read through and manually check the feature test for this story

Any background context you want to provide?

module Starbucks
def self.order(&block)
order = Order.new
order.instance_eval(&block)
return order.drinks
end
class Order
require 'date'
def generate_date do
now = Date.today().to_datetime()
weeks_from_now = Random.rand(8)
day_random = RandomGaussian.new(0.5, 0.25).rand()
day_of_week = (day_random*7+1.5).round() % 7
time_random = RandomGaussian.new(0.5, 0.1).rand()
time = ((time_random*48+12).round() % 48)/2
$(function() {
var counter =0;
function loadNext() {
$('<div>').load('api/thumbnails/whatever/your/url/is?page=' + counter++).appendTo('#thumbnails');
}
$(window).on('scroll', function() {
if ($(document).scrollTop() > document.body.height() - (window.clientHeight / 25)) {
loadNext();
});
context "policy_scope" do
let(:user) { create :user }
let(:admin_user) { create :user, :admin }
let!(:bookings) { create_list :booking, 2 }
let!(:user_bookings) { create_list :booking, 2, user: user }
it "should not include any models for non-admins" do
BookingPolicy::Scope.new(user, Bookings).resolve.tap do |scope|
expect(scope.all.count).to eq 0
end

Keybase proof

I hereby claim:

  • I am mrgenixus on github.
  • I am mrgenixus (https://keybase.io/mrgenixus) on keybase.
  • I have a public key whose fingerprint is 8C09 39C5 4B48 7962 8F65 4F16 66C4 B41B 363C DD51

To claim this, I am signing this object:

Thanks so much for posting this. I have been in far too many of those places; even then the reality isn't as bad as described, in most cases, the person you're dealing with may not be responsible for your bad experience.

As Entrepreneurs and owners, and operators, we should also remember that we employ these people and that when we are in better shape we should find out our employees' stories and support them. If we're doing it right, they are our bread and butter, and we owe the sustainability of our model to them, the future of our business depends, to some degree, on their personal successes and failures, and if they can go on if life gives them a sucker punch.

Ref: the guy at the bar

@mrgenixus
mrgenixus / jquerify.js
Last active August 29, 2015 14:02
jquerify or preprocess the context of a callback(curry the context)
function pre(process, func){
return function(){
return func.apply(process(this), arguments);
}
}
function jquerify (func){ return pre($, func); }
$('div').map(jquerify(function(v, i){
return this.attr('id');