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
<div id="parent" style="width: 80%"> | |
<div id="up" style="float: right; clear: both;">div with id 'up'</div> | |
<div id="down" style="float: right; clear: both;">div with id 'down'</div> | |
'parent' div | |
</div> |
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 } from '@angular/core'; | |
import { Observable } from 'rxjs/Observable'; | |
import { Subject } from 'rxjs/Subject'; | |
import 'rxjs/add/observable/interval'; | |
import 'rxjs/add/operator/map'; | |
import 'rxjs/add/observable/merge'; | |
import 'rxjs/add/operator/startWith'; | |
import 'rxjs/add/operator/scan'; | |
import 'rxjs/add/operator/mapTo'; |
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 } from '@angular/core'; | |
import { Observable } from 'rxjs/Observable'; | |
import { Subject } from 'rxjs/Subject'; | |
import 'rxjs/add/observable/interval'; | |
import 'rxjs/add/operator/map'; | |
import 'rxjs/add/observable/merge'; | |
import 'rxjs/add/operator/startWith'; | |
import 'rxjs/add/operator/scan'; | |
@Component({ |
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 } from '@angular/core'; | |
import { Observable } from 'rxjs/Observable'; | |
import { Subject } from 'rxjs/Subject'; | |
import 'rxjs/add/observable/interval'; | |
import 'rxjs/add/operator/map'; | |
import 'rxjs/add/observable/merge'; | |
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html', |
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
class MyDirective implements ng.IDirective { | |
restrict = 'A'; | |
require = 'ngModel'; | |
templateUrl = 'myDirective.html'; | |
replace = true; | |
constructor(private $location: ng.ILocationService, private toaster: ToasterService) { | |
} | |
link = (scope: ng.IScope, element: ng.IAugmentedJQuery, attrs: ng.IAttributes, ctrl: any) => { |
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Runtime.Caching; | |
namespace CacheProject | |
{ | |
public class CacheLayer | |
{ | |
static readonly ObjectCache Cache = MemoryCache.Default; |
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
You can pass a function to .replaceWith [docs]: | |
$('code').replaceWith(function(){ | |
return $("<pre />", {html: $(this).html()}); | |
}); | |
Inside the function, this refers to the currently processed code element. | |
Update: There is no big performance difference, but in case the code elements have other HTML children, appending the children instead of serializing them feels to be more correct: |
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
//This will sort your array | |
function SortByName(a, b){ | |
var aName = a.name.toLowerCase(); | |
var bName = b.name.toLowerCase(); | |
return ((aName < bName) ? -1 : ((aName > bName) ? 1 : 0)); | |
} | |
array.sort(SortByName); |
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
http://www.klauskomenda.com/code/javascript-programming-patterns/#module |
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
var NewsWidget = (function () { | |
var s; // private alias to settings | |
function somePrivateFunction() { | |
alert("There are " + s.NumArticles + " articles"); | |
} | |
return { | |
settings: { | |
numArticles: 5, | |
articleList: $("#article-list"), |
NewerOlder