Skip to content

Instantly share code, notes, and snippets.

View delonnewman's full-sized avatar

Delon R. Newman delonnewman

View GitHub Profile
function returnCustomStepArray(num1, num2, step){
let myArray = [];
//Edge Cases
//Receive only numbers
if(typeof num1 !== "number" || typeof num2 !== "number" || typeof step !== "number"){
throw new Error("type error; numbers are expected");
}
//Round numbers down
@delonnewman
delonnewman / range.js
Last active August 17, 2023 02:35
elisa
function return1StepArray(num1, num2, step) {
let myArray = [];
//Edge Cases
//Check if there are three values:
if (!num1 || !num2 || !step) {
return "Input three numbers.";
}
//Receive only numbers
if (
# @see https://ruby-naseby.blogspot.com/2008/11/traits-in-ruby.html
module Trait
class RequiredMethodMissing < RuntimeError; end
def append_features( mod )
unless mod.is_a? Class #not the best check, probably...
list_of_methods = ( [ mod.get_required_methods ] << @required_methods ).flatten
mod.required_methods( *list_of_methods.compact )
else
@required_methods.each do | id |
require 'ruby2d'
class Pt
attr_reader :x, :y
def self.[](x, y)
raise TypeError, "no implicit conversion of #{x.class} to Numeric" unless x.is_a?(Numeric)
raise TypeError, "no implicit conversion of #{y.class} to Numeric" unless y.is_a?(Numeric)
obj = allocate
def method_query(object:, args: [], output:)
object.methods.select { |m| begin object.dup.public_send(m, *args) == output; rescue => e; nil end }
end
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <assert.h>
// We'll have 128 tokens. Each token can be up to 32 characters long.
char token[128][32];
int lexer(char* input) {
@delonnewman
delonnewman / round.js
Created February 22, 2022 01:21
Round to the Nearest 15 minute
Math.round(minutes / 15) * 15
function MovieMaker(name) {
var ticketsSold = 0;
document.write(
`<div className="Movie" id="movie-${name}">
<h4>${name}</h4>
<button id="Buyone-${name}">Buy one</button>
<button id="Familypack-${name}">Family pack</button>
</div>`
);
require 'stringio'
require 'erb'
class Event
end
class MorphList
include Enumerable
def self.empty
# get some ideas from https://github.com/zkat/genfun, https://www.npmjs.com/package/protoduck, and https://www.npmjs.com/package/@zkat/protocols
module X
module Generic
Any = BasicObject
DefaultArgs = [Any]
def define_generic_method(name, *args, &blk)
if args.empty?
raise TypeError, "Useless use of a generic method, you should have some arguments, otherwise a normal method is preferrable"
end