Skip to content

Instantly share code, notes, and snippets.

View diestrin's full-sized avatar

Diego Barahona diestrin

View GitHub Profile
var changeValueForPath = function (obj, path) {
var key;
path = path ? path + "." : "";
for (key in obj) {
if (Object.prototype.toString.call(obj[key]) === '[object Object]') {
obj[key] = doTheThing(obj[key], path + key);
} else {
obj[key] = path + key
}
@diestrin
diestrin / jquery-ui-requirejs.coffee
Last active June 29, 2018 10:51
A requirejs configuration file for jquery UI
window.require =
baseUrl: 'scripts'
paths:
jquery: '../bower_components/jquery/jquery'
'jquery-ui': '../bower_components/jquery-ui'
'ui.accordion': 'jquery-ui/ui/jquery.ui.accordion',
'ui.autocomplete': 'jquery-ui/ui/jquery.ui.autocomplete',
'ui.button': 'jquery-ui/ui/jquery.ui.button',
'ui.core': 'jquery-ui/ui/jquery.ui.core',
class MyCtrl
$inject: ['$scope', 'aService']
constructor: (@$scope, @aService) ->
@aValue = 5
someAwesomeFunction: (param1) =>
@aService.someCall param1
app.controller 'MyCtrl', MyCtrl
@diestrin
diestrin / script.js
Created August 10, 2014 04:19
Angular - $digest already in progress - fix
if (!($scope.$$phase || $rootScope.$$phase)) {
$scope.$digest();
}
@diestrin
diestrin / hello.js
Created September 6, 2014 16:15
Hello combinations
(function (word) {
word = word.split('');
var combinations = [], max = factorial(word.length);
function factorial (number) {
if (number <= 1) return 1;
return factorial(number - 1) * number;
}
!function () {
@diestrin
diestrin / project.sublime-project
Created February 11, 2015 21:39
Sublime Folder Structure
{
"folders":
[
{
"follow_symlinks": true,
"name": "Designs",
"path": "/path/to/repo/jcr_root/etc/designs"
},
{
"follow_symlinks": true,
@diestrin
diestrin / gate.service.ts
Last active November 1, 2019 11:04
Reduce Pattern in TypeScripe
// lib imports
import {ReplaySubject} from 'rxjs/ReplaySubject';
// src imports
import {Reducer, IReducerAction, IReduceCases} from './reducer';
export enum GateActions {
OPEN,
CLOSE,
TOGGLE
};
(function () {
'use strict';
function ConsumerController ($scope, Service) {
this.init = function () {
Service.subscribeToEventName($scope, function (e, data) {
// do something
}, this);
};
import {NgModule} from '@angular/core';
import {Awesome} from './awesome.base';
import {AwesomeServer} from './awesome.server';
@NgModule({
providers: [
{provide: Awesome, useClass: AwesomeServer}
]
})
export class App {}
import { NgModule, Injectable } from '@angular/core';
import {
Request,
Response,
XHRBackend,
JSONPBackend,
RequestMethod
} from '@angular/http';
import {
NodeBackend,