Skip to content

Instantly share code, notes, and snippets.

Stewart Charles lennyferguson

Block or report user

Report or block lennyferguson

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
@lennyferguson
lennyferguson / fontsizes.py
Last active Jan 14, 2019
Example of a function that generates a range of font sizes from min -> max -> min modeling the traversal of a sin wave
View fontsizes.py
from typing import List, TypeVar, Callable
from math import sin, pi
# TypeVar for a generic number type
Num = TypeVar('Num', int, float)
"""
Function that generates a List of integers that represent a interpolation of font sizes from min to max along
a sin wave function that has been transformed to have the desired properties.
Returns a List of Integers (List[int]) of size num_pages containing font sizes interpolated between min and max.
@lennyferguson
lennyferguson / generics.go
Last active Aug 22, 2018
Hacky approach to generics in go
View generics.go
func AllMatch(arr interface{}, test func(interface{})bool) bool {
switch reflect.TypeOf(arr).Kind() {
case reflect.Array,reflect.Slice:
a := reflect.ValueOf(arr)
for i := 0; i < a.Len(); i++ {
if !test(a.Index(i).Interface()) {
return false
}
}
}
View view.clj
(defprotocol ToCard
"Protocol for coercing a CardItem to a card"
(to-card [card] "Produces a bootstrap styled card item"))
(defrecord CardItem [title content img-link link]
ToCard
(to-card [_]
[:div.card.bg-dark.text-white
[:a.card-top {:href link}
[:img.card-img-top {:src img-link}]]
View TestResultModels.py
from django.db import models
from functools import reduce
class Result:
passed = 1
failed = 2
skipped = 3
def count_results(results, result):
return reduce(lambda accum, current: accum + (current.result_id == result),
View TestAssertion.java
/**
* Asserts that there is a row on the Student Grades Page that contains every field of each
* Grade in the students list of Grades
* @param student the argument student
* @return the invoked student grades page
*/
public StudentGradesPage assertStudentGrades(final StudentManager.SummaryStudent student) {
Assert.assertTrue(student.getStudentGrades().size() > 0);
final SelenideElement gradesBody = Util.demand($("div.panel-heading + table tbody"));
Assert.assertTrue(student.getStudentGrades().stream().allMatch(grade ->
View SetupTestUsers.java
/**
* QaUser type that encapsulates information displayed for StudentSummary
* which involves enrolled classes, and grades
*/
public class SummaryStudent extends QaUser {
private List<StudentGrade> studentGrades;
private List<StudentClass> studentClasses;
/**
@lennyferguson
lennyferguson / polyhedral_circle_approx.py
Last active Apr 18, 2018
Draw Bot script that creates and renders an approximation of a circle by subdividing a polyhedron
View polyhedral_circle_approx.py
import math
from functools import reduce
"""
Vector Class to handle 2D transformations and operations
"""
class Vec2(object):
def __init__(self, x,y):
self.x = x
self.y = y
@lennyferguson
lennyferguson / quadcopter_src.js
Created Apr 5, 2018
Source Code for Quadcopter Animation
View quadcopter_src.js
/* Author: Stewart Charles
/ Assignment 3
/ CS 4600
/ Version: 2/20/2017
-- Utilizes Matrix Stack and Shape/Objects to draw Quadcopter*/
/* Initialize Variables persistent variables. */
var time;
var xSlider, xText, ySlider, yText;
You can’t perform that action at this time.