Skip to content

Instantly share code, notes, and snippets.

View ktusznio's full-sized avatar
🥙
might be eating a pita

Kamil Tusznio ktusznio

🥙
might be eating a pita
View GitHub Profile
@ktusznio
ktusznio / day-18.js
Last active December 19, 2021 04:46
day-18.js
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);
}
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 &&
### 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:
@ktusznio
ktusznio / _hero.scss
Created July 28, 2017 16:44
Responsive SASS mixins for retina displays
.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/[email protected]');
onSectionSubmit = (sectionConfig, options = {}) => {
var applicationData = this.props.applicationData;
if (!applicationData.isAuthenticated()) {
applicationData.fetch().done(data => {
var sectionConfigs = this.state.sectionConfigs;
sectionConfigs.push(this.getNextSectionConfig(sectionConfig));
this.setState({sectionConfigs});
this.scrollToLastSection();
});
return;
var $ = require('jQuery');
var _ = require('_');
var React = require('react');
var FinancingApplicationView = require('financing/views/FinancingApplicationView.react.jsx');
var FinancingConstants = require('financing/FinancingConstants.js');
var FinancingApplicationData = require('financing/models/FinancingApplicationData.js');
var FinancingApplicant = require('financing/models/FinancingApplicant.js');
var activeApplicant = new FinancingApplicant();
class LRUCache
MAX_SIZE = 3
def initialize
@cache = {}
@max_size = MAX_SIZE
@lru_list = List.new
end
def get(key)
def solution(strengths, weights, connections)
# simulate the order by going through the conections and building the graph
# at each step, evaluate the graph to detect breaks
# at each step, attach the weight, then travel up the graph and check for breaks O(n * log(n))
# data structure:
# node(parent_node, strength, weight (incl. children), children)
# map(i: node)
# create root node
class InFlip
initialize: (options) ->
@set 'stripe_token', new Threadflip.StripeToken(options.stripeToken)
fetchStripeToken: ->
@get('stripe_token').fetch()
class BaseView extends Backbone.View
template: ""
# Render hooks.
beforeFirstRender: ->
beforeRender: ->
afterRender: ->
afterFirstRender: ->
render: =>