Skip to content

Instantly share code, notes, and snippets.

@jackofseattle
jackofseattle / injectable.js
Last active August 29, 2015 14:07
Basic injectable class for AngularJS
/**
* injectable
*
* Provides a constructor to move items from the $inject property to local object members.
*
* inject = ['$q', '$http'] //translates to
*
* this.$q
* this.$http
*/
'use strict';
/* jasmine specs for controllers go here */
/* Define all the services and controllers module, so they are accessable in your it's
*/
describe('controllers', function(){
beforeEach(function(){
module('cotd.controllers');
module('cotd.services');
function averageSalary(employees: Employee[], conditions: Predicate[]): number {
let total = 0;
let count = 0;
employees.forEach((e) => {
if(conditions.every(c => c(e))){
total += e.salary;
count += 1;
}
});
//for a dynamically loaded application
// <script src="system.js">
// <script src="system.config.js">
// <script>
// System.import('app');
// </script>
//for a prebuilt app
var Builder = require('systemjs-builder');
@azat-co
azat-co / JSFUN.md
Last active February 7, 2020 12:22
JavaScript FUNdamentals

JS FUNdamentals

If it's not fun, it's not JavaScript.

Expressiveness

Programming languages like BASIC, Python, C has boring machine-like nature which requires developers to write extra code that's not directly related to the solution itself. Think about line numbers in BASIC or interfaces, classes and patterns in Java.

On the other hand JavaScript inherits the best traits of pure mathematics, LISP, C# which lead to a great deal of expressiveness (and fun!).

@toddb
toddb / build-tasks.ps1
Created August 9, 2011 06:34
Build tasks for powershell via psake
<#
Basic build tasks for SharePoint (or other projects) - using 7zip and GacUtil
$framework = '4.0x64'
. .\scripts\build-tasks.ps1
properties {
$project = "Sites"
@samuelcastle
samuelcastle / cloudformation-eb-apidestinations-demo.yaml
Last active April 18, 2021 08:20
Amazon EventBridge API Destinations demo - Cloudformation template
AWSTemplateFormatVersion: 2010-09-09
Parameters:
MailchimpMembersUrl:
Type: String
Default: https://xxx.api.mailchimp.com/3.0/lists/230948/members
MailchimpApiPassword:
Type: String
Default: REPLACEME
Set-ExplorerOptions -showHidenFilesFoldersDrives -showProtectedOSFiles -showFileExtensions
Enable-RemoteDesktop
cinst 1password
cinst 7zip
cinst 7zip.install
cinst AdobeAIR
cinst adobereader
cinst Atom
cinst markdownpad2
@addyosmani
addyosmani / pubsub.md
Created October 28, 2011 06:49
Four ways to do Pub/Sub with jQuery 1.7 and jQuery UI (in the future)

#Four Ways To Do Pub/Sub With jQuery and jQuery UI (in the future)

Between jQuery 1.7 and some of work going into future versions of jQuery UI, there are a ton of hot new ways for you to get your publish/subscribe on. Here are just four of them, three of which are new.

(PS: If you're unfamiliar with pub/sub, read the guide to it that Julian Aubourg and I wrote here http://msdn.microsoft.com/en-us/scriptjunkie/hh201955.aspx)

##Option 1: Using jQuery 1.7's $.Callbacks() feature:

$.Callbacks are a multi-purpose callbacks list object which can be used as a base layer to build new functionality including simple publish/subscribe systems. We haven't yet released the API documentation for this feature just yet, but for more information on it (including lots of examples), see my post on $.Callbacks() here:

@btroncone
btroncone / rxjs_operators_by_example.md
Last active July 16, 2023 14:57
RxJS 5 Operators By Example