Skip to content

Instantly share code, notes, and snippets.

View erikringsmuth's full-sized avatar

Erik Ringsmuth erikringsmuth

View GitHub Profile
### Keybase proof
I hereby claim:
* I am erikringsmuth on github.
* I am erikringsmuth (https://keybase.io/erikringsmuth) on keybase.
* I have a public key whose fingerprint is FD33 95B4 E70F B775 06C2 A19F 284D 1484 243D D5B8
To claim this, I am signing this object:
@media (min-height: 1080px) {
body {
background: url(https://i.imgur.com/pLXlyrR.jpg) no-repeat fixed bottom right;
}
}
@erikringsmuth
erikringsmuth / Overview.md
Last active August 29, 2015 14:05
jasmine2-amd-specrunner with jasmine-jquery

I played around with this and got it to a point where I'm not getting errors anymore. I'm not sure if it actually works though...

First, put jasmine-jquery.js in the root folder (next to amdSpecRunner.js).

You won't be able to load jasmine-jquery.js with a normal <script> tag. You have to load it with RequireJS so that you can specify it's dependency on jasmine. That way the code in jasmine-jquery.js won't be executed until jasmine has been loaded.

amdSpecRunner.js

  • line 19: specify it's dependency on jasmine
  • line 31: load jasmine-jquery
@erikringsmuth
erikringsmuth / gulpfile.js
Last active August 29, 2015 14:05
gulp jshint web components
gulp.task('lint', function() {
gulp.src(['src/*.js', 'src/*.html'])
.pipe(jshint.extract('always'))
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('jshint-stylish'));
});
alert('java zcript!');
@erikringsmuth
erikringsmuth / JavaScript DI and Modules.md
Last active March 24, 2017 10:15
JavaScript DI and Modules

Here's a more in depth explanation of Angular's DI, RequireJS, and what's coming up in Angular 2.0 and ES6 modules.

Angular DI is not a module loader! It injects objects that have already been loaded using script tags. It does not do lazy-loading. Angular 2.0 will use ES6 import for module loading. Angular 2.0 will also add a DI layer that runs after the modules load.

I need to go over Java's import vs. JavaScript's require/import and Java singletons to further explain what Angular's DI is doing.

Java's import allows you to access another package's types without fully qualifying the package name. JavaScript's import loads a module and creates references to the module's exported objects. These are very different operations. JavaScript's import is powerful stuff! You have the objects, not just aliases to a package's types.

Singleton is a pattern, not the object itself. In Java you start with a type and have to create an instance. The singleton pattern ensures you have only 1 instance of that t

@erikringsmuth
erikringsmuth / di.js
Last active August 29, 2015 14:01
DI vs. Module Loader
// The DI pattern assumes that MyService will be a class or constructor function
import {MyService} from './myService';
@Inject(MyService)
export class MyThing {
constructor(myService) {
this.myService = myService;
}
someAction() {
@erikringsmuth
erikringsmuth / createSession.js
Last active March 3, 2016 15:27
Node Google OAuth 2.0 Login using OpenID Connect
'use strict';
var googleOAuth2 = require('./googleOAuth2'),
clientId = '...',
clientSecret = '...';
// DON'T STORE YOUR CLIENT ID AND SECRET, GET THEM FROM YOUR CONFIG!
module.exports.createOAuthTokens = function createOAuthTokens(req, res) {
// view.on - delegate events. These are bound once to the root object so subsequent calls to view.render()
// don't need to re-bind events. Events work differently than jQuery delegate events since there aren't
// native ECMAScript delegate events. jQuery swapped event.target and event.currentTarget. Who knows why...
//
// var MyView = View.extend({
// this.on: {
// 'click span a': function(event) {
// this; // will reference your instance of `MyView`
// event.target; // will reference the DOM element the action took place on. This is `a` in this example.
// event.currentTarget; // will reference `this.el` which is the root element that all events are bound to.