Skip to content

Instantly share code, notes, and snippets.

View mrister's full-sized avatar
🏠
Working from home

Mihovil Rister mrister

🏠
Working from home
View GitHub Profile
@mrister
mrister / Ubuntu.16.04 LTS install scrcpy from source
Created January 7, 2021 23:22
Steps to install scrcpy to Ubuntu 16.04 from source
#!/usr/bin/env bash
# fail if any commands fails
set -e
# debug log
set -x
echo "starting install"
add-apt-repository main
add-apt-repository universe
add-apt-repository restricted
@mrister
mrister / app.module.ts
Last active September 1, 2017 07:55
Logging to Loggly from Angular application
// To configure an external lib like loggly-tracker follow these steps
// 1. Either download or in your index.html add areference to a Loggly script
// <script type="text/javascript" src="//cloudfront.loggly.com/js/loggly.tracker-2.1.min.js"></script>
// 2. In typings.d.ts file declare the Loggly global variable like:
// declare var LogglyTracker;
// 3. You should be all set to use the LogglyTracker
import {BrowserModule} from '@angular/platform-browser';
import {ErrorHandler, Injectable, NgModule} from '@angular/core';
import {AppComponent} from './app.component';
@mrister
mrister / error-log.service.ts
Last active September 1, 2017 07:53
AngularJS logging with date information
@Injectable()
export class ErrorLogService {
private name: String = 'ErrorLogService';
constructor() {
}
logError(error: any) {
const date = new Date().toISOString();
if (error instanceof HttpErrorResponse) {
console.error(date, 'There was an HTTP error.', error.message, 'Status code:', (<HttpErrorResponse>error).status);
} else if (error instanceof TypeError) {
@mrister
mrister / app.module.ts
Last active September 1, 2017 07:57
AngularJS error handling service to be used in global error handler
import {BrowserModule} from '@angular/platform-browser';
import {ErrorHandler, Injectable, NgModule} from '@angular/core';
import {HttpErrorResponse} from '@angular/common/http';
import {AppComponent} from './app.component';
// Our service to handle errors (ideally in its own file)
@Injectable()
export class ErrorLogService {
private name: String = 'ErrorLogService';
@mrister
mrister / app.module.ts
Created August 23, 2017 13:48
Global UI error handler
import {BrowserModule} from '@angular/platform-browser';
import {ErrorHandler, NgModule, Injectable} from '@angular/core';
import {AppComponent} from './app.component';
@Injectable()
class UIErrorHandler extends ErrorHandler {
constructor() {
super();
}
handleError(error) {
@mrister
mrister / app.module.ts
Created August 22, 2017 20:23
Global catch all AngularJS v2 error handler
import {BrowserModule} from '@angular/platform-browser';
import {ErrorHandler, NgModule} from '@angular/core';
import {AppComponent} from './app.component';
class MyErrorHandler extends ErrorHandler {
constructor() {
super();
}
}
@mrister
mrister / transpiled-loggly-logging.js
Last active July 13, 2017 16:11
Transpiled example of logging to Loggly using Bunyan
'use strict';
var bunyan = require('bunyan');
var Bunyan2Loggly = require('bunyan-loggly');
var log = bunyan.createLogger({
name: 'logglylog',
streams: [{
type: 'raw',
stream: new Bunyan2Loggly({
@mrister
mrister / loggly-es6-example.js
Last active July 13, 2017 16:11
Es6 example of logging to Loggly using Bunyan
const bunyan = require('bunyan');
const Bunyan2Loggly = require('bunyan-loggly');
const log = bunyan.createLogger({
name: 'logglylog',
streams: [
{
type: 'raw',
stream: new Bunyan2Loggly({
token: '<your token>',
@mrister
mrister / .babelrc
Created June 12, 2017 00:25
Babel configuration file to support Node.js v4
{
"presets": [
[
"env",
{
"targets": {
"node": 4
}
}
]
@mrister
mrister / async-await-loggly.ts
Last active June 27, 2017 23:23
Logging to Loggly with async await
// run npm i loggly --save
import * as loggly from 'node-loggly-bulk';
interface LoggingClient {
log(obj: any, cb:Function): any
}
const client: LoggingClient = loggly.createClient({
token: 'YOUR_APPLICATION_TOKEN',
subdomain: 'YOUR_SUBDOMAIN',
json: true