Skip to content

Instantly share code, notes, and snippets.

// ==UserScript==
// @name SPM Custom CSS Properties
// @namespace http://tampermonkey.net/
// @version 0.35
// @description SPM UI theme creation using CSS properties
// @author https://github.com/daithimorton
// @match https://*/*
// @match http://*/*
// @grant none
// @downloadUrl https://gist.github.com/daithimorton/467336d64f1a130ef622499634dd098c/raw/spmcssvar.user.js
module Component
def operation
raise "Component error"
end
end
module Decorator
include Component
def initialize(component)
@component = component
module Component
def operation
raise "Component error"
end
end
module Decorator
include Component
def initialize(component)
// Receiver
class Entity {
String name;
public Entity(String name){
this.name = name;
}
public void jump(){
System.out.println(name + " Jump");
}
public void fire(){
# Command interface
module ICommand
def execute
raise NotImplementedError
end
end
# Concrete commands
class SubmitCommand
// Command
const InsertCommand = (database, id) => {
return {
execute: () => database.insertRecord(id),
undo: () => database.deleteRecord(id)
};
};
// Receiver
const insertRecord = id => console.log('>>> Database insert', id);
@uxdxdev
uxdxdev / true_if_derived.cpp
Created July 23, 2017 19:36
Implement a template function IsDerivedFrom() that takes class C and class P as template parameters. It should return true when class C is derived from class P and false otherwise.
#include <iostream>
using namespace std;
class B {
};
class A : public B {
};
template<typename D, typename B>
@uxdxdev
uxdxdev / Parity.cpp
Last active January 27, 2023 16:46
EPI C++ 5.1 Computing the parity of a word
#include <iostream>
#include <sstream>
#include <map>
using namespace std;
std::map<unsigned int, short> parityCache;
short parityOf(unsigned long x){
short result = 0;
while(x){
@uxdxdev
uxdxdev / Utils.h
Created January 7, 2017 15:32
Utils class
// Copyright 2016 David Morton. All rights reserved.
// Use of this source code is governed by a license that can be
// found in the LICENSE file.
#ifndef BASE_UTILS_H
#define BASE_UTILS_H
#include <iostream>
class Utils {
@uxdxdev
uxdxdev / UtilsTest.cpp
Last active January 27, 2023 16:47
Unit tests for Utils class
// Copyright 2016 David Morton. All rights reserved.
// Use of this source code is governed by a license that can be
// found in the LICENSE file.
#include "gtest/gtest.h"
#include "Base/Utils.h"
TEST(UtilsTest, to_strCanConvertIntZeroToString) {
std::string result = Utils::to_str(0);
ASSERT_EQ("0", result);