Skip to content

Instantly share code, notes, and snippets.

View pedrohugorm's full-sized avatar

Pedro Matos pedrohugorm

View GitHub Profile
@pedrohugorm
pedrohugorm / DomainEvents.cs
Last active February 21, 2018 18:45
One Simple Domain Event Publisher
using System.Collections.Generic;
using System.Linq;
namespace Core.DomainEvents
{
public interface IDomainEvent
{
}
@pedrohugorm
pedrohugorm / Component.ts
Last active January 5, 2018 15:51
Angular Simple Sort Column Component
module adp.hosted.crm.directives {
interface ISortState {
readonly showUpward: boolean;
readonly showDownward: boolean;
readonly value: string;
next(): ISortState;
}
@pedrohugorm
pedrohugorm / InfiniteScrollPerfTest.js
Last active December 12, 2017 17:21
Infinite Scroll Performance Problem
function isElementInViewport (rect) {
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && /*or $(window).height() */
rect.right <= (window.innerWidth || document.documentElement.clientWidth) /*or $(window).width() */
)
}
@pedrohugorm
pedrohugorm / SyncTime.kt
Last active December 8, 2017 19:44
Sync Time between two devices
import kotlin.*
import kotlin.jvm.*
import java.util.*
import java.lang.*
import java.time.*
import java.time.temporal.*
/**
* We declare a package-level function main which returns Unit and takes
* an Array of strings as a parameter. Note that semicolons are optional.
// Bootstrap Mid-Small - col-ms-* - the missing grid set for Bootstrap3.
//
// This is a hack to fill the gap between 480 and 760 pixels - a missing range
// in the bootstrap responsive grid structure. Use these classes to style pages
// on cellphones when they transition from portrait to landscape.
//
// NOTE: Here I use SASS instead of LESS for styling. To convert to LESS
// replace '$screen' with '@screen' and '$grid' with '@grid'.
//
// See https://github.com/twbs/bootstrap/issues/10203 for more info.
@pedrohugorm
pedrohugorm / container-based-grid.less
Last active June 13, 2017 18:10
Bootstrap Container Based Grid - Using Bootstrap as Reference
@import (reference) "../bootstrap-less/bootstrap.less";
@import "../bootstrap-less/mixins/grid.less";
@max-amount-columns: 12;
.custom-col(@sizeCateg, @col-index: @max-amount-columns, @column-val: @max-amount-columns) when (@col-index > 0) {
(~".col-@{sizeCateg}-@{col-index}") {
& when (@sizeCateg = 'xs'){
@pedrohugorm
pedrohugorm / Directive.ts
Last active May 3, 2017 01:52
Typescript Doubly Linked List
interface ISliderDirectiveScope {
readonly count;
register(sliderItem: ISliderItemDirectiveScope);
deregister(sliderItem: ISliderItemDirectiveScope);
next(): ISliderItemDirectiveScope;
prev(): ISliderItemDirectiveScope;
selectedItem(): ISliderItemDirectiveScope;
class ActionHandler
parent: null
handle: (action) ->
return null
class AlertHandler extends ActionHandler
class ConfirmHandler extends ActionHandler
class ChangeStateHandler extends ActionHandler
class RedirectHandler extends ActionHandler
class ValidationHandler extends ActionHandler
class ModalHandler extends ActionHandler
(function () {
'use strict';
var module = angular.module('modalHelper', []);
module.factory('modalTemplateFath', [
function () {
return {
module: function (fileName) {
@pedrohugorm
pedrohugorm / script.js
Last active January 5, 2016 16:41
Hierarchy SUM function DRAFT
###
Coffeescript test to sum a total value in an object hierarchy
###
class PropostaFormViewRule
constructor: (_) ->
@_ = _
sum: (obj, key) ->
# Remove nulls to avoid NaN/undefined sum