Skip to content

Instantly share code, notes, and snippets.

View leeprobert's full-sized avatar

Lee Probert leeprobert

View GitHub Profile
/**
This is a Widget extension that will automatically export an image of the widget when it is painted onscreen.
We was using this to create symbols for MapBox from Widgets that are generated programmatically.
*/
import 'dart:typed_data';
import 'dart:ui';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
@leeprobert
leeprobert / SliverAppBar.dart
Created March 30, 2021 11:55
A custom SliverAppBar with flexible spaces for the expanded and collapsed state. Includes an option for showing a multiline title with a feature image in the expanded state. When collapsed the two spaces will fade between each other with a single line title for the collapsed space.
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'RootAppBar.dart';
import 'dart:math' as math;
class RootSliverAppBar extends StatefulWidget {
RootSliverAppBar({
Key key,
this.title,
this.actions,
@leeprobert
leeprobert / buildIconMap.sh
Last active December 10, 2021 23:33
File that takes the icons.json from the Font Awesome Flutter library, and creates a Dart file that is a map of the icons that you can reference by string name to get the icon data. These work with the regular and light fonts to give you two map files.
#!/usr/bin/env bash
if [ -e ./icons.json ];
then
echo "Custom icons.json found, using local data only."
dart ./tool/generate_regular_icon_map.dart ./icons.json
dart ./tool/generate_light_icon_map.dart ./icons.json
else
echo "Could not find the local Icons.json file"
fi
@leeprobert
leeprobert / FontAwesomeIconMap.dart
Created March 10, 2021 17:08
FontAwesomeIconMap.dart
library font_awesome_flutter_original;
import 'package:flutter/widgets.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
// import 'package:font_awesome_flutter/icon_data.dart';
// THIS FILE IS AUTOMATICALLY GENERATED!
class FontAwesomeIconsOriginal {
static const Map<String, IconData> icons = {
@leeprobert
leeprobert / firebase_functions.js
Created November 27, 2020 21:09
Simple Firebase function for redirecting to a URL by checking a query string
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const defaultApp = admin.initializeApp(functions.config().firebase);
exports.redirect = functions.https.onRequest((req, res) => {
const redirectId = req.query.id;
console.log(redirectId);
var redirectUrl;
switch(redirectId){
// this is a terminal command to run in the same folder as a bunch of MP3 you want to convert so they work with Alexa. Requires that FFMpeg is installed.
printf "%s\0" * | xargs -0 -I {} ffmpeg -y -i {} -ac 2 -codec:a libmp3lame -b:a 48k -ar 16000 converted_{}
// it prepends the string "converted_" to the output files.
@leeprobert
leeprobert / UIViewSnapshot.swift
Created July 5, 2016 11:23
CoreImage extensions
/*
Extension for UIView for taking a snapshot and blurring it using CoreImage filters.
*/
extension UIView {
func blurredSnapshot() -> UIImage {
func toCIImage(image: UIImage) -> CIImage {
return image.CIImage ?? CIImage(CGImage: image.CGImage!)
}
@leeprobert
leeprobert / NSData+AES.h
Created April 19, 2016 16:02 — forked from matsuda/NSData+AES.h
Objective-C code for encrypt and decrypt by AES-128 encryption.
/**
http://mythosil.hatenablog.com/entry/20111017/1318873155
http://blog.dealforest.net/2012/03/ios-android-per-aes-crypt-connection/
*/
@interface NSData (AES)
- (NSData *)AES128EncryptedDataWithKey:(NSString *)key;
- (NSData *)AES128DecryptedDataWithKey:(NSString *)key;
- (NSData *)AES128EncryptedDataWithKey:(NSString *)key iv:(NSString *)iv;
@leeprobert
leeprobert / input.scss
Created December 3, 2015 11:36
Sass file for my site on leeprobert.cc
@import url('http://weloveiconfonts.com/api/?family=entypo');
/*
VARIABLES
*/
$font-stack: 'Roboto', 'Avenir', Arial, sans-serif;
$grey-color1: #333;
$grey-color2: #444;
$grey-color3: #555;
@leeprobert
leeprobert / p5js - 3D Spikey Plane Ball.markdown
Last active November 16, 2015 10:12
Forked from [Mike Brondbjerg](http://codepen.io/brondbjerg/)'s Pen [p5js - 3D Spikey Plane