Skip to content

Instantly share code, notes, and snippets.

View TheBeege's full-sized avatar

Bryan "Beege" Berry TheBeege

  • Seoul, South Korea
View GitHub Profile
@TheBeege
TheBeege / twisted_http_server.py
Last active August 29, 2015 13:57
Twisted HTTP Server with DB Auth
#!/usr/bin/env python2.7
# README:
# So this puppy won't run as is.
# I've commented out the LogAdapter lines that assign
# the logger var. This is because I strongly, strongly
# recommend you have good logging, take the time to
# setup your logger properly, and customize your
# own logging format. Your operations folks will
# thank you (assuming you log useful stuff).
@TheBeege
TheBeege / main.tac
Created October 5, 2014 23:40
Execute some logic before any children are fulfilled
class Root(Resource):
baseLogger = None
def __init__(self):
self.baseLogger = logging.getLogger('MB-Server.Root')
logger = MBLogAdapter(self.baseLogger, {'file': 'main.tac', 'object': 'Root', 'method': '__init__'})
logger.info('Creating new Root')
var x = prompt("Type something at me");
if (x.indexOf("1") != -1 && x.indexOf("$") != -1 ) {
alert("You entered both a 1 and a $.");
} else if ( x.indexOf("1") != -1 ) {
alert("You entered only a 1");
} else if ( x.indexOf("$") != -1 ) {
alert("You entered only a $");
} else {
alert("Congrats you entered neither a 1 nor a $.");
@TheBeege
TheBeege / variable_access.js
Last active January 4, 2016 23:33
Variable Access
var obj = {};
obj.a = 1;
obj.b = 2;
var reallyA = "a"
console.log("obj.a: " + obj.a);
console.log("obj['a']: " + obj["a"]);
console.log("obj[reallyA]: " + obj[reallyA]);
@TheBeege
TheBeege / nginx.sh
Created February 15, 2016 00:55
NGINX Init Script
#!/bin/sh
#
# Pulled from https://www.nginx.com/resources/wiki/start/topics/examples/redhatnginxinit/ 2016-02-14
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: NGINX is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
@TheBeege
TheBeege / testing_with_inheritance_example.java
Last active December 3, 2016 03:25
Cheat Example for Testing Homework
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
public class Parent {
private List<String> collection;
public Parent(List<String> stuff) {
collection = new ArrayList<>();
for(String item : stuff) {
@TheBeege
TheBeege / Practicum.txt
Created December 10, 2016 09:15
Java Practicum from Scratch
Create a class called LTCMath with a typical main function.
Create a public static function called printSquare that takes in one integer and returns no output. printSquare should print a square whose sides are the length of the integer parameter.
Create a public static function called getEven that takes in an integer array. It should return an array consisting of only the even numbers from the given array.
Create a unit test for getEven. Test it for a normal array, an empty array, an array of only even numbers, and an array of only odd numbers.
Create a second class called Converter.
public class Main {
public static void main(String[] args) {
String testString = "forrk";
String validString = "fork";
char currentChar;
StringBuilder builder = new StringBuilder(testString);
for(int i = 0; i < testString.length(); i++) {
currentChar = builder.charAt(i);
builder.deleteCharAt(i);
System.out.println("Current String: " + builder.toString());
@TheBeege
TheBeege / practicum.txt
Created December 18, 2016 08:53
Python Preholiday Practicum
Create a function called print_square that takes in one integer and returns no output. print_square should print a square whose sides are the length of the integer parameter.
Create a function called get_even that takes in a list of numbers. It should return a list consisting of only the even numbers from the given list.
Create a function to test get_even. It should call get_even with a normal array, an empty array, an array of only even numbers, and an array of only odd numbers as inputs. If it fails to behave as expected, throw an error.
Create a function called convert_c_to_f. It should take in a number as its only parameter. It should return a number that converts the given number from Celsius degrees to Farenheit degrees. The formula for Celsius to Farenheit: Tc * (9/5) + 32.
Call print_square with 5 as an input.
Call convert_c_to_F with today's temperature and print it out.
/*
PROGRAM STRUCTURE
Things in <>'s are meant to be replaced.
import <my import>;
public class <ClassName> {
public static void main(String[] args) {
// logic
}