This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const input = fs.readFileSync("./day-18/input.sample", "utf8").split("\n"); | |
function magnitude(num) { | |
if (typeof num === "number") return num; | |
const [left, right] = num; | |
return 3 * magnitude(left) + 2 * magnitude(right); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// NSManagedObject+KTManagedObject.h | |
// Created by Kamil Tusznio on 12-07-10. | |
// | |
#import <CoreData/CoreData.h> | |
@interface NSManagedObject (KTManagedObject) | |
+ (NSArray *)fetchAll; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function loadSegment(writeKey) { | |
if (!writeKey) { | |
throw new Error("loadSegment: blank writeKey."); | |
} | |
var analytics = (window.analytics = window.analytics || []); | |
if (!analytics.initialize) | |
if (analytics.invoked) | |
window.console && | |
console.error && |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am ktusznio on github. | |
* I am ktusznio (https://keybase.io/ktusznio) on keybase. | |
* I have a public key ASA4KeJnQKl5ok63_6cNVA9r4R51CFiBzKJ8OErfoZvgawo | |
To claim this, I am signing this object: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.hero { | |
background: url('/images/hero-mobile.jpg') no-repeat center center; | |
background-size: cover; | |
@include breakpoint(tablet) { | |
background-image: url('/images/hero.jpg'); | |
} | |
@include retina { | |
background-image: url('/images/hero-mobile@2x.jpg'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class InFlip | |
initialize: (options) -> | |
@set 'stripe_token', new Threadflip.StripeToken(options.stripeToken) | |
fetchStripeToken: -> | |
@get('stripe_token').fetch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BaseView extends Backbone.View | |
template: "" | |
# Render hooks. | |
beforeFirstRender: -> | |
beforeRender: -> | |
afterRender: -> | |
afterFirstRender: -> | |
render: => |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe Foo do | |
let(:big_params) do | |
{ | |
foo: foo, | |
name: "name", | |
... | |
} | |
end | |
let(:foo) { nil } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def available_if_enough_info | |
if self.available? || self.display_only? | |
if self.can_be_available? | |
self.available! | |
else | |
self.display_only! | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe Purchase do | |
let(:have_1) { FactoryGirl.build_stubbed(:have, asking_price: 15) } | |
let(:have_2) { FactoryGirl.build_stubbed(:have, asking_price: 20) } | |
describe "#amount_for_haves" do | |
let(:amount_for_haves) { purchase.amount_for_haves([have_1, have_2], credit, promo) } | |
let(:credit) { 0 } | |
let(:expected_amount_for_haves) do | |
# Order haves by asking_price, high to low. | |
have_2_expected_amount_hash.merge(have_1_expected_amount_hash) |
NewerOlder