Skip to content

Instantly share code, notes, and snippets.

View ClassicThunder's full-sized avatar
🏠
Working from home

Scott Franks ClassicThunder

🏠
Working from home
View GitHub Profile
@ClassicThunder
ClassicThunder / grouping.scala
Last active September 12, 2021 20:31
Example of how to group together rows in spark based on an indicator.
import org.apache.spark.sql.SparkSession
import org.apache.spark.sql.expressions.Window
import org.apache.spark.sql.functions._
import org.apache.log4j.{Level, Logger}
// // build.sbt
// name := "sparktest"
//
// version := "0.1"

OOP Crash Course

OOP

Object Oriented Programming is all about encapsulating moving parts into self-sustainable objects.

Self-sustainable means they contain both logic and the data that logic operates on.

There are 4 main concepts of OOP

OOP Exercise

Exercise

For this assignment you will apply OO principles to represent an email message.

How emails work:

  • All emails must have the following features
  • Recipients

public void calcD(double d, double h, String n, String t, double r, int a, List i, List ae, List m) { double d2 = 0;

switch (t) {
    case "m":
        d2 = d * r;
    case "ps":
        d2 = d * (a * .05);
        if (i.contains("sh"))

if (rand.nextInt(10) <= 4) d2 += 20;

Instructions

Give the class 30m to find as many code smells as possible.

LineItem

package com.nq.util;
 
@ClassicThunder
ClassicThunder / Interface.java
Last active August 27, 2015 17:33
Examples
public interface IDebitable
{
public double GetBallance();
public void Debit(double amount);
public void Credit(double amount)
}
debitTest()
{
IDebitable atm = new ATMMachine();
@ClassicThunder
ClassicThunder / PremultiplyAlpha.cs
Last active August 29, 2015 14:20
Premultiply Alpha for textures loaded via FromStream
Texture2D file;
RenderTarget2D result;
using (var titleStream = TitleContainer.OpenStream(loc)) {
file = Texture2D.FromStream(graphicsDevice, titleStream);
}
//Setup a render target to hold our final texture which will have premulitplied alpha values
result = new RenderTarget2D(graphicsDevice, file.Width, file.Height);
@ClassicThunder
ClassicThunder / WindowsHook.cs
Created May 9, 2015 21:13
Allows subscribing to windows events in a project not using windows forms.
using System;
using System.Runtime.InteropServices;
namespace Microsoft.Xna.Framework.Input
{
public class CharacterEventArgs : EventArgs
{
private readonly char character;
@ClassicThunder
ClassicThunder / Images.md
Last active August 29, 2015 14:19
Objective-c reference.

###Generating a screenshot

- (UIImage *)screenshot
{
    CGSize imageSize = CGSizeZero;
    
    imageSize = CGSizeMake([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
    
    UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0);