I hereby claim:
- I am pdbradley on github.
- I am pdbradley (https://keybase.io/pdbradley) on keybase.
- I have a public key ASD5GtzA3z5X7nNf451URVza1LKYC1CUf3Joimi7p7X2Ago
To claim this, I am signing this object:
require 'pry' | |
class Image | |
def initialize(image) | |
@image = Marshal.load(Marshal.dump(image)) | |
end | |
def output_image | |
@image.each do |x| | |
puts x.join |
class King < ChessPiece | |
# King specific methods ... | |
def valid_move?(x_target, y_target) | |
return false if same_location?(x_target, y_target) | |
return false if !in_board?(x_target, y_target) | |
return true if move_single_step?(x_target, y_target) | |
return false | |
end |
require 'rails_helper' | |
RSpec.describe King, type: :class do | |
describe '.valid_move?' do | |
it "should check for valid move for a King" do | |
user = FactoryGirl.create(:user) | |
piece = FactoryGirl.create(:king, user_id: user.id) | |
piece.x = 4; piece.y = 4; piece.color = "white" | |
expect(piece.valid_move?(piece.x+1, piece.y+0)).to eq(true) |
# assuming a column called encrypted password, and you need to | |
# get access to the plaintext to do work, put these getters | |
# and setters in your class to magically get what you need | |
def password | |
Base64.decode64(self.encrypted_password) | |
end | |
def password=(string) |
products = Product.by_company(current_user.company.slug).includes(:facilities, :total_stocks).distinct(:sku) | |
sql = "SELECT DISTINCT ON (product_id) * FROM facility_stocks WHERE product_id IN (#{@products.pluck(:id).join(', ')}) ORDER BY product_id, created_at DESC" | |
facility_stocks = ActiveRecord::Base.connection.execute(sql) | |
facilities = Facility.all # or whatever conditions you are putting on that | |
# then construct a collection of stuff you want to show in the view. | |
# Basic principle: don't calculate anything in a view unless absolutely necessary | |
# "separation of concerns" helps you know where to look for your logic |
class AddTriggerForInvoiceAmount < ActiveRecord::Migration[5.1] | |
def change | |
reversible do |dir| | |
dir.up do | |
execute <<-SQL | |
CREATE OR REPLACE FUNCTION calculate_invoice_current_balance() | |
RETURNS trigger AS $calc_invoice_balance$ | |
BEGIN | |
IF (TG_OP = 'DELETE') THEN |
#= require framework7.bundle.js | |
var f7_app = new Framework7({ | |
// App root element | |
root: '#app', | |
// App Name | |
name: 'My App', | |
// App id | |
id: 'com.myapp.test', | |
// Enable swipe panel |
class dontGetIt { | |
constructor() { | |
this.foo = 'hello'; | |
} | |
hello() { | |
this.foo; | |
} | |
} |
set runtimepath^=~/.vim runtimepath+=~/.vim/after | |
let &packpath = &runtimepath | |
source ~/.vimrc | |
let g:python2_host_prog = '/usr/local/bin/python' | |
let g:python3_host_prog = '/usr/local/bin/python3' |
I hereby claim:
To claim this, I am signing this object: