Skip to content

Instantly share code, notes, and snippets.

Avatar

Michael Marner MichaelMarner

View GitHub Profile
View cached_image_hero.dart
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) => MaterialApp(
title: 'CachedNetworkImage Hero',
theme: ThemeData(primarySwatch: Colors.blue),
View cached_image_problems.dart
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) => MaterialApp(
title: 'CachedNetworkImage Demo',
theme: ThemeData(primarySwatch: Colors.blue),
View dialog.dart
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
home: MyHomePage(title: 'Flutter Demo Home Page'),
View restart-error-handler.ts
import { ErrorHandler, Inject } from '@angular/core';
import { AlertController } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
export class MyErrorHandler implements ErrorHandler {
constructor(
private alerts: AlertController,
public splashScreen: SplashScreen,
) {}
View restart-and-log.ts
import { ErrorHandler, Inject } from '@angular/core';
import { AlertController } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
Import { RollbarService } form 'angular-rollbar';
export class MyErrorHandler implements ErrorHandler {
constructor(
private alerts: AlertController,
public splashScreen: SplashScreen,
public rollbar: RollbarService
View rollbar-init.ts
@NgModule({
imports: [
RollbarModule.forRoot({
accessToken: 'YOUR ROLLBAR CLIENT TOKEN'
})
],
});
View module-init-1.ts
const ERROR_HANDLER = environment.production ? MyErrorHandler : IonicErrorHandler;
@NgModule({
// the rest of your module bootstrapping
providers: [
{ provide: ErrorHandler, useClass: ERROR_HANDLER }
]
});
View gist:56be1a84cb20d0b5fcb9f0ed6fed43aa
import { ErrorHandler } from '@angular/core';
export class MyErrorHandler implements ErrorHandler {
constructor() {}
async handleError(error) {
console.error(error);
}
}
View binary-serverless.yml
service: image-resizer
plugins:
- serverless-apigw-binary
- serverless-apigwy-binary
custom:
apigwBinary:
types:
- 'image/jpeg'
@MichaelMarner
MichaelMarner / lambda.ts
Last active Nov 3, 2017
Lambda image resize APIGateway
View lambda.ts
import { APIGatewayEvent, Context, Callback } from 'aws-lambda';
import * as Jimp from 'jimp';
export async function resize(
event: APIGatewayEvent,
context: Context,
callback: Callback
) {
const image = await Jimp.read(event.queryStringParameters.src);
await image.cover(Number(event.queryStringParameters.w), Number(event.queryStringParameters.h));