This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# @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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def method_query(object:, args: [], output:) | |
object.methods.select { |m| begin object.dup.public_send(m, *args) == output; rescue => e; nil end } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Math.round(minutes / 15) * 15 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>` | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'stringio' | |
require 'erb' | |
class Event | |
end | |
class MorphList | |
include Enumerable | |
def self.empty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
NewerOlder