Skip to content

Instantly share code, notes, and snippets.

View Vintharas's full-sized avatar
👶
Parenting

Jaime Vintharas

👶
Parenting
View GitHub Profile
@Vintharas
Vintharas / .block
Last active August 21, 2019 20:54
Simple example circle
license: mit
@Vintharas
Vintharas / .block
Last active August 21, 2019 20:43
Simple example moving divs
license: mit
@Vintharas
Vintharas / gulp.config.js
Last active July 17, 2018 07:59
Sample gulpfile for a complete pipeline with ES6 and SASS
/* eslint strict: [2, "global"] */
'use strict';
/*** Main paths ***/
var projectRoot = './',
root = './myProject.web/', // project root
index = root + 'Views/Shared/Layouts/',
src = root + 'Content/', // source code
temp = root + 'temp/', // temporary folder
dist = src + 'dist/', // generated code
@Vintharas
Vintharas / random-attendee.js
Last active April 5, 2017 08:57 — forked from mzabriskie/random-attendee.js
Select random Meetup attendee
// Create bookmark with javascript: CODE_HERE
// Click on bookmark in meetup website
(function () {
var list = document.getElementById('rsvp-list').children,
item = list[Math.floor(Math.random() * list.length)],
name = item ? item.querySelector('h5.member-name a').innerHTML : 'N/A';
item && item.parentNode.removeChild(item);
alert("And the winner!!! Is.... " + name);
@Vintharas
Vintharas / memoize.js
Last active January 22, 2016 17:11
Memoize using a promise (angular $q)
/*
*
* Memoizes call to a service using a promise
*
*/
function memoizeWithPromise(getFn) {
let memoizedCalls = new Map();
return function(...args) {
let serializedArgs = JSON.stringify(args);
@Vintharas
Vintharas / knockout-subscribables.js
Created June 2, 2013 19:33
Subscribers to knockout observables are notified as soon as the observable changes
// src/subscribables/subscribable.js
"notifySubscribers": function (valueToNotify, event) {
event = event || defaultEvent;
if (this._subscriptions[event]) {
ko.dependencyDetection.ignore(function() {
ko.utils.arrayForEach(this._subscriptions[event].slice(0), function (subscription) {
// In case a subscription was disposed during the arrayForEach cycle, check
// for isDisposed on each subscription before invoking its callback
@Vintharas
Vintharas / knockout-observables-with-object-values.js
Last active December 18, 2015 00:09
By default knockout notifies subscribers of a change when an object value is written, even if it is identical to the old one
// spec/observableBehaviors.js
it('Should notify subscribers of a change when an object value is written, even if it is identical to the old value', function() {
// Because we can't tell whether something further down the object graph has changed, we regard
// all objects as new values. To override this, set an "equalityComparer" callback
var constantObject = {};
var instance = new ko.observable(constantObject);
var notifiedValues = [];
instance.subscribe(notifiedValues.push, notifiedValues);
instance(constantObject);
expect(notifiedValues).toEqual([constantObject]);
@Vintharas
Vintharas / ngDirective.js
Last active September 24, 2015 13:20
Angular directive ReSharper Live Template
/*
* $description$ directive.
*
* Usage:
* <vtf-$directiveName$></vtf-$directiveName$>
*
*/
(function () {
'use strict';
@Vintharas
Vintharas / gist:f0d29f39662f282d6ca0
Created March 2, 2015 13:46
AutoFixture MVC Controller Customization
public static class ModelStateTestHelpers
{
public static bool HasError(this ModelStateDictionary modelState, string errorMessage)
{
return modelState.Any(ms => ms.Value.Errors.Any(e => e.ErrorMessage == errorMessage));
}
}
@Vintharas
Vintharas / gist:aaa4d760308d0b9af177
Created March 2, 2015 13:46
MVC, ModelState Helpers, HasErrors
public static class ModelStateTestHelpers
{
public static bool HasError(this ModelStateDictionary modelState, string errorMessage)
{
return modelState.Any(ms => ms.Value.Errors.Any(e => e.ErrorMessage == errorMessage));
}
}