Skip to content

Instantly share code, notes, and snippets.

astronomy88

Block or report user

Report or block astronomy88

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View notable.ipynb
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 Apr 6, 2018
Converting Binary to Integer
View binary_to_int.py
B = '1101'
I = 0
while B != '':
I = I * 2 + (ord(B[0]) - ord('0'))
B = B[1:]
@astronomy88
astronomy88 / queue_ll.rb
Last active Aug 11, 2016
Queue implementation with linked lists
View queue_ll.rb
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 Jul 12, 2016
Stack implementation with Linked Lists
View stack_ll.rb
require './node'
class StackLinkedList
attr_reader :length
def initialize(item)
@first = Node.new(item)
@first.next = nil
@length = 1
@astronomy88
astronomy88 / node.rb
Created Jul 12, 2016
Node Class to use in a Linked List
View node.rb
class Node
attr_accessor :item, :next
def initialize(item)
@item = item
end
end
@astronomy88
astronomy88 / queue.rb
Last active Feb 11, 2016
Implementing a queue with an Array
View queue.rb
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 Feb 11, 2016
Implementing a Stack class using an Array
View stack.rb
class Stack
attr_reader :length, :stack
def initialize(size=1)
@stack = Array.new(size)
@length = 0
end
def is_empty?
View storm-kafka-pom.xml
<!--
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>
View python_producer_kaka.py
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")
View binary_search.rb
def binary_search x, low = 0, high = -1
#-- Assume that a is already sorted
a = [3, 5, 7, 8, 10, 11, 14, 15, 26, 33, 34, 36, 39, 40, 41, 44, 45, 48, 49]
high = a.length - 1 if high == -1
midpoint = (high + low) / 2
if low == midpoint
You can’t perform that action at this time.