Skip to content

Instantly share code, notes, and snippets.

@martinobordin
martinobordin / AngularRxJs5DateHttpInterceptor.ts
Last active September 22, 2023 08:23
An Angular interceptor to parse string dates (ISO8601 format) from server response to JS Date Object. There are both RxJs 5 and RxJs 6 versions
import { Injectable } from '@angular/core';
import { HttpRequest, HttpHandler, HttpEvent, HttpInterceptor, HttpErrorResponse, HttpResponse } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/do';
@Injectable()
export class AngularDateHttpInterceptor implements HttpInterceptor {
// Migrated from AngularJS https://raw.githubusercontent.com/Ins87/angular-date-interceptor/master/src/angular-date-interceptor.js
iso8601 = /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(([+-]\d\d:\d\d)|Z)?$/;
@adamrecsko
adamrecsko / highlight.pipe.ts
Created May 1, 2016 20:28
Angular2 text highlight pipe
import {PipeTransform, Pipe} from 'angular2/core';
@Pipe({ name: 'highlight' })
export class HighLightPipe implements PipeTransform {
transform(text: string, [search]): string {
return search ? text.replace(new RegExp(search, 'i'), `<span class="highlight">${search}</span>`) : text;
}
}
/** Usage:
@btroncone
btroncone / rxjs_operators_by_example.md
Last active June 15, 2024 07:17
RxJS 5 Operators By Example
@btroncone
btroncone / ngrxintro.md
Last active February 9, 2024 15:37
A Comprehensive Introduction to @ngrx/store - Companion to Egghead.io Series

Comprehensive Introduction to @ngrx/store

By: @BTroncone

Also check out my lesson @ngrx/store in 10 minutes on egghead.io!

Update: Non-middleware examples have been updated to ngrx/store v2. More coming soon!

Table of Contents

@bettysteger
bettysteger / formErrorsSvc.js
Last active January 16, 2018 10:14
Angular Form Group Directive and Form Errors Service (sets validities depending on server response)
/**
* Handles form errors from server.
*/
app.factory('formErrors', function () {
return {
/**
* Creates $error.errorKey (String) and sets validity
* for every failing model validation received from the server.
* E.g. 'form.message.$error.errorKey' can be accessed in the view.
@weberste
weberste / gist:354a3f0a9ea58e0ea0de
Last active January 28, 2022 13:47
Dates only with Angular-UI Bootstrap datepicker
app.directive('datepickerLocaldate', ['$parse', function ($parse) {
var directive = {
restrict: 'A',
require: ['ngModel'],
link: link
};
return directive;
function link(scope, element, attr, ctrls) {
var ngModelController = ctrls[0];
public EdgeEffect(Context context) {
final Resources res = context.getResources();
mEdge = res.getDrawable(R.drawable.overscroll_edge);
mGlow = res.getDrawable(R.drawable.overscroll_glow);
@rachelbaker
rachelbaker / install-yeoman-osx.md
Last active October 4, 2019 21:33
Instructions for installing Node NPM and Yeoman on OSX
@brettkelly
brettkelly / example.py
Created February 25, 2013 19:21
findNotesMetadata example
filter = NoteStore.NoteFilter()
filter.ascending = False
spec = NoteStore.NotesMetadataResultSpec()
spec.includeTitle = True
ourNoteList = noteStore.findNotesMetadata(authToken, filter, 0, 100, spec)
@morkai
morkai / results-ubuntu.txt
Created October 5, 2012 13:22
node.js cwd on Windows
root@ubuntu:/workspace/node/cwd# uname -a
Linux ubuntu 2.6.35-30-generic #61-Ubuntu SMP Tue Oct 11 15:29:15 UTC 2011 i686 GNU/Linux
root@ubuntu:/workspace/node/cwd# node -v
v0.8.11
root@ubuntu:/workspace/node/cwd# node test-node.js
Test 1
exec cmd = node cwd.js
exec cwd = undefined
FAILED (AS IT SHOULD) :>
expected process cwd =