Skip to content

Instantly share code, notes, and snippets.

View leeprobert's full-sized avatar

Lee Probert leeprobert

View GitHub Profile
@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
/**
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 / 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){
@leeprobert
leeprobert / ScreenCaptureView.m
Created May 7, 2013 08:30
A UIView subclass for recording the screen and saving as a file. Credit to Aroth from CodeThink. From this blog entry : http://aroth.no-ip.org:82/wordpress/archives/673
//
//ScreenCaptureView.h
//
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
/**
* Delegate protocol. Implement this if you want to receive a notification when the
* view completes a recording.
*
// 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 / NSUserDefaults+registerDefaultsFromSettingsBundle.m
Last active June 9, 2017 16:23
Thanks to http://ijure.org/wp/archives/179 for this code that registers the Settings bundle defaults with the NSUserDefaults class.
- (void)registerDefaultsFromSettingsBundle
{
NSLog(@"Registering default values from Settings.bundle");
NSUserDefaults * defs = [NSUserDefaults standardUserDefaults];
[defs synchronize];
NSString *settingsBundle = [[NSBundle mainBundle] pathForResource:@"Settings" ofType:@"bundle"];
if(!settingsBundle)
{
@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;