Skip to content

Instantly share code, notes, and snippets.

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.
@astronomy88
astronomy88 / binary_to_int.py
Created April 6, 2018 05:09
Converting Binary to Integer
B = '1101'
I = 0
while B != '':
I = I * 2 + (ord(B[0]) - ord('0'))
B = B[1:]
@astronomy88
astronomy88 / queue_ll.rb
Last active August 11, 2016 05:47
Queue implementation with linked lists
require './node'
class QueueLinkedList
attr_reader :length
def initialize(item)
@q = Node.new item
@q.next = nil
@current = @q
@astronomy88
astronomy88 / stack_ll.rb
Created July 12, 2016 03:51
Stack implementation with Linked Lists
require './node'
class StackLinkedList
attr_reader :length
def initialize(item)
@first = Node.new(item)
@first.next = nil
@length = 1
@astronomy88
astronomy88 / node.rb
Created July 12, 2016 03:45
Node Class to use in a Linked List
class Node
attr_accessor :item, :next
def initialize(item)
@item = item
end
end
@astronomy88
astronomy88 / queue.rb
Last active February 11, 2016 07:20
Implementing a queue with an Array
class Queue
attr_reader :queue, :tail, :head
def initialize
@head_pos = 0
@tail_pos = 0
@queue = Array.new(1)
end
@astronomy88
astronomy88 / stack.rb
Last active February 11, 2016 06:39
Implementing a Stack class using an Array
class Stack
attr_reader :length, :stack
def initialize(size=1)
@stack = Array.new(size)
@length = 0
end
def is_empty?
<!--
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>
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")