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 Solution(object): | |
def start_index_search(self, intervals, value, lower, upper): | |
""" Return the index that contains the value, or else one right below it""" | |
if len(intervals) == 1: | |
return 0 | |
mid = lower + ((upper - lower) // 2) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
B = '1101' | |
I = 0 | |
while B != '': | |
I = I * 2 + (ord(B[0]) - ord('0')) | |
B = B[1:] |
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
require './node' | |
class QueueLinkedList | |
attr_reader :length | |
def initialize(item) | |
@q = Node.new item | |
@q.next = nil | |
@current = @q |
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
require './node' | |
class StackLinkedList | |
attr_reader :length | |
def initialize(item) | |
@first = Node.new(item) | |
@first.next = nil | |
@length = 1 |
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 Node | |
attr_accessor :item, :next | |
def initialize(item) | |
@item = item | |
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
class Queue | |
attr_reader :queue, :tail, :head | |
def initialize | |
@head_pos = 0 | |
@tail_pos = 0 | |
@queue = Array.new(1) | |
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
class Stack | |
attr_reader :length, :stack | |
def initialize(size=1) | |
@stack = Array.new(size) | |
@length = 0 | |
end | |
def is_empty? |
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
<!-- | |
Bind the maven-assembly-plugin to the package phase | |
this will create a jar file without the storm dependencies | |
suitable for deployment to a cluster. | |
--> | |
<plugin> | |
<artifactId>maven-assembly-plugin</artifactId> | |
<configuration> | |
<descriptorRefs> | |
<descriptorRef>jar-with-dependencies</descriptorRef> |
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
from kafka import * | |
mykafka = KafkaClient("localhost:9092") | |
producer = SimpleProducer(mykafka) | |
producer.send_messages("test", "mymessage") | |
producer.send_messages("test", "mymessage 2") | |
producer.send_messages("test", "mymessage 3") | |
producer.send_messages("test", "mymessage 4") |
NewerOlder