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
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 LRUCache
MAX_SIZE = 3
def initialize
@cache = {}
@max_size = MAX_SIZE
@lru_list = List.new
end
def get(key)
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();
@ktusznio
ktusznio / gist:935156
Created April 21, 2011 18:16
Script to hash up the intl_users csv
def make_hash
f = File.new("/tmp/intl_users_with_name_and_email")
out = open("/tmp/intl_users_json", "w")
proxy_emails = 0
blank_names = 0
total = 0
while (line = f.gets)
begin
@ktusznio
ktusznio / jquery-namespace.js
Created June 22, 2011 22:43
A simple jQuery namespacing function
/**
* Introducing the $.namespace function! It takes a string and gives you a
* global representing the namespace you want.
*
* For example, $.namespace("Causes.Earn.Dialog") => {Earn: {Dialog: {}}}
*
* This gets rid of crufty code like:
*
* if (!Causes) { Causes = {}; }
* if (!Causes.Earn) { Causes.Earn = {}; }
@ktusznio
ktusznio / html
Created August 28, 2011 01:26 — forked from raila/html
batman keypath test
# Create our application and namespace.
class Alfred extends Batman.App
@global yes
# setup our root route. When the app starts up, it will automatically call TodosController::index
@root 'todos#index'
# Define the principal Todo model with `body` and `isDone` attributes, and tell it to persist itself using Local Storage.
class Alfred.Todo extends Batman.Model
@ktusznio
ktusznio / gist:1249409
Created September 28, 2011 22:17
Simple Batman App
<!DOCTYPE html>
<html>
<head>
<title>Test App</title>
<script type="text/javascript" src="../lib/es5-shim.js"></script>
<script type="text/javascript" src="../lib/batman.js"></script>
<script type="text/javascript" src="../lib/batman.solo.js"></script>
<script type="text/javascript" src="../lib/coffee-script.js"></script>
</head>
<body>
@ktusznio
ktusznio / gist:1334781
Created November 2, 2011 20:23
Batman Associations Sample
<!DOCTYPE html>
<html>
<head>
<title>Alfred: Batman's Todos</title>
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="resources/alfred.css" type="text/css">
<script type="text/javascript" src="../lib/es5-shim.js"></script>
@ktusznio
ktusznio / controller.coffee
Created January 10, 2012 21:24
Batman Filtering
class Shopify.OrdersController extends Shopify.ApplicationController
index: (params) ->
@allOrders = Shopify.Order.get('all')
@_filterOrders()
addFilter: (type, value) ->
@set "#{type}Filter", value
@_filterOrders()
_filterOrders: ->
@ktusznio
ktusznio / gist:1790846
Created February 10, 2012 16:53
batman.js checkbox example
<!DOCTYPE html>
<html>
<head>
<title>Test App</title>
<script type="text/javascript" src="../lib/es5-shim.js"></script>
<script type="text/javascript" src="../lib/batman.js"></script>
<script type="text/javascript" src="../lib/batman.solo.js"></script>
<script type="text/javascript" src="../lib/extras/batman.rails.js"></script>
<script type="text/javascript" src="../lib/coffee-script.js"></script>
</head>