Questions tagged [mixins]

A mixin is a way to enhance an object with properties or methods from another object.

Filter by
Sorted by
Tagged with
1
vote
1answer
41 views

Proper naming for objects which have a position and bounds on a plane

I have an interface which is for an object which has bounds in a 2D plane. ...
3
votes
0answers
64 views

Boilerplate-free mixin pattern for a TypeScript charting library

The TypeScript handbook provides a mixin pattern but it requires a bunch of boilerplate, doesn't work for getters/setters and doesn't support defining default values (or any constructor work) in the ...
2
votes
2answers
293 views

SASS mixin for a font-awesome before/after usage

In my SASS I use font-awesome declarations all over the place. I'm in love with it. I've created a SASS mixin for the usage: I started with the following: ...
2
votes
1answer
216 views

SASS/SCSS mixin for button states

I have created several mixins for a button to attempt to reduce duplication and contribute to the overall improvement of performance. I am looking for guidance on how to tighten this up so it is as ...
2
votes
1answer
194 views

Less CSS Mixin for positioning with options for corresponding top, left, right, bottom values

I've created a Mixin in Less CSS. It can do the following things: Set the position-rule of an element. Place the element in one of the corners (e.g. top left, bottom right etc.) Alternatively it can ...
7
votes
1answer
192 views

Create six hash tables - 2 hashing schemes x 3 collision handling schemes

I was asked to solve the following task: Given two methods for hashing (division and multiplication) and three methods for collision handling (chaining, open addressing w/ quadratic probing, ...
1
vote
1answer
111 views

Applying a set of styles both with a media query and with nested rules

I am working on an application which responds to different screen resolutions. At a certain minimum DPI, we want to apply a set of styles. We also want to apply that same set of styles if the class <...
2
votes
0answers
78 views

Copy-on-write in Ruby

I need to return private collection and avoid calling code modifying them avoiding copying overhead if possible So I thought of returning copy-on-write arrays, hashes, and sets. I couldn't find any ...
1
vote
0answers
29 views

Sass-Mixin for to attach a text-shadow animation upon HTML-elements

I've make these mixins by using SCSS-Sass. Any hints and tipps concerning improvements are welcomed. ...
2
votes
1answer
37 views

SASS mixin to define modifier classes for various screen sizes

I wish to make a mixin to produce the following result of modifier classes: ...
1
vote
1answer
99 views

JavaScript inheritance with super calls and mixins

I needed JavaScript inheritance that offered calling of overridden methods (super calls). Furthermore I needed a possibiliy to add behaviour to instances (mixins). Mixins should not only be full ...
2
votes
0answers
52 views

ActiveAdmin menu-generating mixin

I've written an ActiveAdmin mixin, such that you can include it and call simple_menu_for Foo, to reduce duplicate code when working with simple models. Here is the ...
3
votes
1answer
64 views

Implicit type class for updating maps

With the help of SO I got my code working, but I think it still could be improved, in particular I do not like using asInstanceOf. Is there some way how to avoid it?...
2
votes
0answers
186 views

Mixin implementation helper

While implementing things like repositories we often can see that reading and writing parts can be done totally independently. The same time client side will win from the single reference (who wants ...
8
votes
1answer
354 views

A Mixin Comparator class

Idea: In C++, often a straightforward implementation of comparison operators is needed. In C++11, they can be conveniently implemented using std::tie. The following ...
4
votes
2answers
86 views

Simple Translation Gem

I have a small gem that I've been maintaining. This gem provides a simple way to do translation using an alternative Google API. I've been working with Java last year and recently did some ...
4
votes
0answers
77 views

Creating companion classes that are `inherited` onto any sub-classes

The idea for the code I have written came about due to the acts_as_versioned gem which automatically nests a Version class onto ...
1
vote
0answers
37 views

IUnitTest, INonCopyable, and IMapKey mixins

I am creating a boiler-plate namespace that will allow me to ensure proper coding practices are followed and avoid gotchas. Looking over my code below; can you see any "no-no's" or gotchas? Can you ...
2
votes
2answers
136 views

Simulating MixIns with Java

I am using the following technique for simulating mixins (or Traits) using Java and would like to know whether this is reasonable or just confusing to future developers. Also, I believe a good naming ...
3
votes
0answers
116 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
528 views

More elegant Sass @mixin to create pseudo-element shapes

I picked up Sass last week, and I'm already diving into expressions. I have a @mixin that creates a CSS border triangle using the following call: ...
4
votes
1answer
201 views

Utility library and Underscore mixin - 1

This code is similar to Underscore. I've added in some functions to fill in different use cases. For example, one can use someKey to iterate through ...
7
votes
2answers
4k views

Policy-based, variadic logger class in C++

I've been exploring design based around some of the more advanced C++11 features lately, and some of them are turning out to be rather useful for some projects I'm working on. One is this policy-based,...
2
votes
0answers
130 views

Modification of the headline line-height in the Compass vertical rhythm module

One thing nagged me about the compass vertical rhythm module; in the case the headline is too long and it occupies more than one line the line-height between the two lines looks way too massive and ...
2
votes
1answer
84 views

JavaScript mixins, extending and super methods

I've read a lot of stuff about mixins, inheritance and such, and in the end I came up with this solution for extending a class with multiple mixins. I haven't seen this anywhere else... Is this a ...
0
votes
1answer
326 views

JavaScript mixins - extending and super methods [closed]

I've read a lot of stuff about mixins, inheritance and such, and in the end I came up with this solution for extending a class with multiple mixins. I haven't seen this anywhere else... ...
2
votes
0answers
261 views

Blade (similar to Jade) template with SCSS

I have this blade template with a main.scss file: ...
10
votes
1answer
390 views

Mixin and template-heavy code for a Silverlight clone

I've made a mock version of Silverlight in D2. It is meant to output HTML, but since I don't know HTML yet, its current output is in. HTML is not the reason I'm here, though. The goal of my project ...
5
votes
1answer
4k views

Multiple inheritance Mixin class

I've written a simple class that somewhat simulates multiple inheritance using mixins. It allows you to extend the functionality of multiple classes and manage any conflicts between them, should they ...