Meta-programming is the writing of computer programs with the ability to treat programs as their data. It means that a program could be designed to read, generate, analyze and/or transform other programs, and even modify itself while running.
2
votes
0answers
36 views
Automatic flowchart generator
I wanted to see graphically what my programme was doing so I wrote this automatic flowchart generator:
...
3
votes
2answers
103 views
Building a chain of responsibility in Ruby to apply transformators on an object
I try to make a middleware stack system in the rack way (but not for HTTP request).
Here is the main class:
...
3
votes
1answer
81 views
Meta-class to allow inspection of all __slots__of a class
If classes provide __slots__ and at the same time inherit from another class also providing __slots__, there is no ...
2
votes
2answers
66 views
Synchronous and asynchronous motor movement
I am working on an API that is mostly intended to be used interactively/little scripts. There are some classes with methods that could act slightly differently depending on the intention of the user, ...
2
votes
1answer
67 views
Memoization of Fibonacci using generic Int => Int helper
I'm trying to understand memoization using Scala. I took the Fibonacci sequence as an example because of the high cost of recursively computing numbers in the sequence without memoization.
...
8
votes
2answers
129 views
Find arity of a rebol function
I needed a way to find the number of arguments a function or operation in Rebol accepts (the functions arity). I could not find any direct support for this in the language, so I made my own ...
2
votes
0answers
52 views
Making a default value a property
I recently asked a question on StackOverflow, looking for a way to more easily turn a class attribute into a @property, but only if no other value has been provided ...
4
votes
0answers
51 views
Creating 2D vectors
I've made a little mechanism for creating 2-D vectors in Lua. Vectors have two components i and j, and support addition, dot ...
3
votes
0answers
45 views
Extracting dynamic behaviors of state machines to modules
This is my initial class. (I am not trying to reinvent state-flows again, just practicing)
As you can see straight forward, it dynamically generates methods like .recommend,.recommend!, ...
3
votes
1answer
89 views
Enums for measurement units, with possible circular dependency
I have some enums that define measurement information, such as volume, mass, distance etc...
They are defined as such:
...
2
votes
0answers
101 views
Efficient compile-time directed graph
During my research in Rigid Body Dynamics, (where Contact Graphs are used to solve the contact problem) I came across the question if it is possible to define at compile time a directed graph (class) ...
4
votes
1answer
78 views
Dictionary with restricted keys
I'm currently building some software that works with systemd unit files, and I've been trying to improve how we construct the unit files.
This is all running in Python 3.4
This first block is the ...
2
votes
2answers
392 views
Failing fast by raising an exception with a custom message
This is a script that utilizes lazy exception throwing. What I do is decorate a function that might throw an exception to throw an exception with a formatted string.
...
12
votes
2answers
752 views
Wait, is that variable ever assigned?
One of the inspections we wanted to implement in Rubberduck for the next release, is one that finds all unassigned variables in a VBA project.
Implementing this inspection has been ...complicated ...
17
votes
3answers
303 views
Rubberduck's “Extract Method” refactoring implementation
With the ANTLR-powered parser, I was able to reimplement all code inspections from the last release build, and the rest of the inspections on the road map are now implementable.
Code inspections ...
5
votes
2answers
257 views
Java MVC model for large scale GUI using annotations
I'm trying to make a good MVC model using annotations, which I will use it in a large scale GUI project. I want to respect the maximum of rules and guidelines, and be able to decorrelate every parts ...
0
votes
1answer
54 views
Python decorator for optional arguments decorator
I want my Python decorators to have optional arguments and not be called when not necessary.
The accepted answer in here doesn't accept named arguments, and I don't want to add boilerplate code ...
4
votes
1answer
96 views
Universal memoization decorator
I've just written a simple caching / memoization python decorator. It's purpose is to cache what the function returns for all the arguments combinations it's been ever invoked with.
So, if, say, we ...
6
votes
1answer
132 views
Wrapping the classList API to add/remove array of classes
I've written a function that wraps the classList API, allowing you to pass an array of classes to add/remove, or the variable arguments already supported by ...
2
votes
0answers
36 views
Is monkeypatching __builtin__ in tests like this an absurdly complicated practice?
My hunch: Probably.
I'm testing a little magic behaviour of my script that automatically reads from ~/.ghtoken to do automagic authentication on GitHub API ...
8
votes
2answers
121 views
Generating and calling code on the fly
Delegate
This class module defines what I'm calling, in this context, a Delegate - here a function that can take a number of parameters, evaluate a result, and ...
10
votes
3answers
173 views
Ugly workaround to get the vbext_ProcKind of a procedure is breaking encapsulation
This is a follow up to Extending the VBAExtensibility Library. It turns out that code had a really nasty bug. Anytime vbeProcedure.StartLine got called, I was ...
13
votes
5answers
242 views
Automagic testing framework for VBA
Building on @RubberDuck's recommendations, I now have something I find... beautiful. I'm sure there's a couple of things left to polish - this site is about making great code out of good any code, ...
6
votes
1answer
153 views
Multiple dispatch decorator classes in Python
This is based on my first review and the suggested points in "Multiple dispatch decorator in Python":
...
3
votes
1answer
84 views
General way to add persistence to a class in Python
The idea here is to write a function that gives you back a persistent version of a class that you supply. So you if you run
...
1
vote
0answers
12 views
Memcache Keys Management Class
I have written below class to manage Memcache keys.
My Memcache keys structure are like:
...
7
votes
3answers
408 views
VB6/VBA Declaration (Dim) Syntax Parser
As part of a project I'm working on, I've implemented a class that encapsulates the syntax for a vb6/vba Dim statement.
Given a line of code, the ...
7
votes
1answer
778 views
Extending the VBA Extensibility Library
The Microsoft Visual Basic for Applications Extensibility library let's us meta-program VBA, but the way it handles (or rather, doesn't handle) getting to the actual subs and functions is clunky at ...
3
votes
3answers
376 views
Math Equation Solver
I made this math script, where you enter an equation and it solves it for you. I was wondering what you thought of the code, and what I could have done better or what doesn't follow Ruby best ...
5
votes
1answer
86 views
Zombie Smack Down game
So about a year and a half ago, me and my friend started on a game called Zombie Smack Down. It's a text based game written in Ruby. But we were both really new to Ruby when most of it was written. I ...
3
votes
1answer
97 views
Ruby 1.9 interner
I'm currently implementing an interner in the style of Guava's Interner, where:
an intern pool is maintained for an immutable class
whenever a new instance of ...
2
votes
1answer
146 views
Streamlining repetitive class definitions in python with a class_factory() function
I forked this repo to be more concise. The code is here. I'll paste it below since that seems to be the style. I removed the class definitions at the bottom that I didn't change -- the edit I'm ...
2
votes
1answer
559 views
define_method vs method_missing and CodeClimate scores
This may be a better fit for another board, but here goes:
I've made a very simple gem that acts as a days-of-the-week bitmask. To be hip, I registered it on CodeClimate, where it's currently scoring ...
3
votes
1answer
123 views
Perl wrapper library (written using Moose) for a REST API
I wrote a wrapper library for a REST API (https://semantics3.com) in Perl using the Moose library. I would like to gather some feedback on it (mainly on the OOP part since I am new to moose), before ...