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 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 |
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 LRUCache | |
MAX_SIZE = 3 | |
def initialize | |
@cache = {} | |
@max_size = MAX_SIZE | |
@lru_list = List.new | |
end | |
def get(key) |
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
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(); |
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 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 |
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
/** | |
* 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 = {}; } |
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
# 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 |
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
<!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> |
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
<!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> |
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 Shopify.OrdersController extends Shopify.ApplicationController | |
index: (params) -> | |
@allOrders = Shopify.Order.get('all') | |
@_filterOrders() | |
addFilter: (type, value) -> | |
@set "#{type}Filter", value | |
@_filterOrders() | |
_filterOrders: -> |
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
<!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> |
OlderNewer