Skip to content

Instantly share code, notes, and snippets.

View neptunius's full-sized avatar
🌈

Alan Davis // Rainbow neptunius

🌈
View GitHub Profile
@neptunius
neptunius / API_response.json
Last active May 7, 2020 00:51
API Response JSON Format – Ben Lafferty's BK Tree
// PROTOTYPE
// API route format: api.ben.com/<query:str>/<distance:int>
// Request example: api.ben.com/hello/2
// Response JSON:
{
"exact": ["hello"],
"close": ["cell", "cello", "helio", "helix", "hell", ...]
}
// RECOMMENDED – API standards: https://github.com/WhiteHouse/api-standards
@neptunius
neptunius / binarytree.py
Created December 16, 2019 08:36
Helper method to create a printable visual string representation of a binary search tree
class BinaryTreeNode:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
class BinarySearchTree:
def __init__(self):
self.root = None
@neptunius
neptunius / litebrite.py
Last active October 9, 2019 03:14
Rainbow code for Dani's Lite Brite activity – client: make.sc/litebrite-client and server: make.sc/litebrite-repo
from math import sin, cos, radians
import os
import pusher
# Step 1: Change YOUR_NAME to your own name!
YOUR_NAME = 'Rainbow'
# Step 2: Choose a color and assign it to YOUR_COLOR.
# HINT 1: Value should always be a six character hex code with a # in front.
# HINT 2: Find colors that will look good in the demo here: https://github.com/yeun/open-color#available-colors
@neptunius
neptunius / madlibs.py
Created September 11, 2019 22:06
Code snippets to show how to reduce line length and complexity
madlib = (madlib.replace(word_type, input("Enter a {}: ".format(word_type)), 1))
prompt = "Enter a {}: ".format(word_type)
user_word = input(prompt)
madlib = madlib.replace(word_type, user_word, 1)
################################################################################
for x in range(len(stories[story]["words"])):
stories[story]["words"][x] = input(stories[story]["words"][x] + ": ")
@neptunius
neptunius / cs-1.1-01-snippets.py
Last active August 28, 2019 21:41 — forked from ibirnam/cs-1.1-01-snippets.py
code snippets used for the first class of CS 1.1
# CS-1.1 Variables, Function, and Program Design
def greet_by_name(name):
greeting = "Hello, " + name + "!"
return greeting
print(greet_by_name("Alan"))
# Hello, Alan!
print(greet_by_name("Jess"))

Cracking WSP Encryption

Project Background

An unnamed government security agency has recently begun intercepting numerous messages encrypted with a state of the art, never before seen algorithm. Because everything in government needs an acronym, the application of this algorithm has been nicknamed "WSP Encryption."

Up to this point in time, a team of seven highly paid PhD analysts has been staffed to manually decrypt each and every WSP-encrypted message they receive. The analysts have not slept or eaten in twelve days, and many of them are beginning to face burnout. Meanwhile, the stack of encrypted messages continues to grow.

As a frantic last ditch effort, the director of the unnamed agency performed a late night PRISM search to identify a coder capable of automating the decryption processes. As a top Make School student, YOU have been selected to carry out this task!

@neptunius
neptunius / squareup.py
Created February 8, 2019 09:02
Asim's square up coding challenge
#!python3
def square_up(n):
"""Simple test cases in docstring
>>> square_up(2)
[0, 1, 2, 1]
>>> square_up(3)
[0, 0, 1, 0, 2, 1, 3, 2, 1]
>>> square_up(4)
@neptunius
neptunius / recursion.py
Last active March 31, 2016 00:44
Comparison of iterative and recursive functions
import unittest
def factorial(n):
"""factorial(n) returns the product of the integers 1 through n for n >= 0,
otherwise raises ValueError for n < 0 or non-integer n"""
# implement factorial_iterative and factorial_recursive below, then
# change this to call your implementation to verify it passes all tests
# return factorial_iterative(n)
return factorial_recursive(n)
#!/usr/local/bin/python3
class Node(object):
def __init__(self, data=None):
self.data = data
self.next = None
def __str__(self):
/*==================================================================================================================
Copyright (c) 2010 - 2014 Leap Motion. All rights reserved.
The intellectual and technical concepts contained herein are proprietary and confidential to Leap Motion, and are
protected by trade secret or copyright law. Dissemination of this information or reproduction of this material is
strictly forbidden unless prior written permission is obtained from Leap Motion.
===================================================================================================================*/