- History
- Fundamentals
- Types
- Flow Control
- Functions and Objects
- Modern JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.load-modal { | |
display: none; | |
position: fixed; | |
z-index: 1000; | |
top: 0; | |
left: 0; | |
height: 100%; | |
width: 100%; | |
background: rgba(255, 255, 255, .8) | |
url("img/ajax-loader.gif") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let shuffle (arr : _[]) = | |
let rnd = new System.Random() | |
let swap a b (arr : _[]) = | |
let temp = arr.[a] | |
arr.[a] <- arr.[b] | |
arr.[b] <- temp | |
for i in 0..arr.Length-1 do | |
swap i (rnd.Next(arr.Length)) arr | |
arr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!flask/bin/python | |
from flask import Flask, jsonify, abort, make_response, request | |
app = Flask(__name__) | |
tasks = [ | |
{ | |
'id': 1, | |
'title': u'Buy groceries', | |
'description': u'Milk, Cheese, Pizza, Fruit, Tylenol', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Reasonable defaults | |
var PIXEL_STEP = 10; | |
var LINE_HEIGHT = 40; | |
var PAGE_HEIGHT = 800; | |
function normalizeWheel(/*object*/ event) /*object*/ { | |
var sX = 0, sY = 0, // spinX, spinY | |
pX = 0, pY = 0; // pixelX, pixelY | |
// Legacy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { BehaviorSubject, Observable } from 'rxjs/Rx'; | |
@Injectable() | |
export class EmployeeStore { | |
private _selectedEmployees: BehaviorSubject<any[]> = new BehaviorSubject([]); | |
public selectedEmployees: Observable<any[]> = this._selectedEmployees.asObservable(); | |
addOrRemoveEmployee (employee) { | |
let existingEmployee = this._selectedEmployees.getValue() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (Test-Path dist) { | |
Remove-Item dist -Recurse -Force | |
} | |
if (Test-Path build) { | |
Remove-Item build -Recurse -Force | |
} | |
$NGC = "node_modules/.bin/ngc.cmd" | |
$ROLLUP = "node_modules/.bin/rollup.cmd" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { BehaviorSubject } from 'rxjs/BehaviorSubject'; | |
import { Observable } from 'rxjs/Observable'; | |
@Injectable() | |
export class AppState { | |
private _isRed = new BehaviorSubject<boolean>(false); | |
isRed: Observable<boolean> = this._isRed.asObservable(); | |
toggleRed() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, Input, HostBinding } from '@angular/core'; | |
import { AppState } from './app.state'; | |
@Component({ | |
selector: 'hello', | |
template: ` | |
<h1>Hello Data Store!</h1> | |
<button (click)="toggleRed()">Toggle Red</button> | |
` | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { Observable } from 'rxjs/Observable'; | |
import { Subscriber } from 'rxjs/Subscriber'; | |
@Injectable() | |
export class WebsocketService { | |
private ws: WebSocket; | |
createObservableSocket(url: string, openSubscriber: Subscriber<any>): Observable<any> { | |
this.ws = new WebSocket(url); |
OlderNewer