Skip to content

Instantly share code, notes, and snippets.

Avatar

Lee Probert leeprobert

View GitHub Profile
@leeprobert
leeprobert / firebase_functions.js
Created Nov 27, 2020
Simple Firebase function for redirecting to a URL by checking a query string
View firebase_functions.js
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){
View Convert_MP3_for_Alexa
// 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.
View UIViewSnapshot.swift
/*
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 Apr 19, 2016 — forked from matsuda/NSData+AES.h
Objective-C code for encrypt and decrypt by AES-128 encryption.
View NSData+AES.h
/**
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 Dec 3, 2015
Sass file for my site on leeprobert.cc
View input.scss
@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 Nov 16, 2015
Forked from [Mike Brondbjerg](http://codepen.io/brondbjerg/)'s Pen [p5js - 3D Spikey Plane
View p5js - 3D Spikey Plane Ball.markdown
View Country.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>001</key>
<string>Afghanistan</string>
<key>002</key>
<string>Albania</string>
<key>003</key>
<string>Algeria</string>
@leeprobert
leeprobert / StyleManager.swift
Last active Nov 5, 2015
StyleManager port to Swift 2. The class loads the plist by getting the filename from the project info.plist. The plist allows core UIKit components to be styled very easily. The StyleManager class is a Singleton and just needs to be initialised in the app delegate to style the app.
View StyleManager.swift
//
// StyleManager.swift
// HoboApp
//
// Created by WLD_MBP_20 on 04/11/2015.
// Copyright (c) 2015 probert. All rights reserved.
//
import UIKit
@leeprobert
leeprobert / form_kit.html
Last active Aug 29, 2015
A bunch of things that are useful in a HTML5 form
View form_kit.html
<!-- Regular expression for UK postcodes -->
<label for=postcode>Postcode<span class="red">*</span></label>
<input name=postcode type=text aria-required required pattern="[0-9]{5}(\-[0-9]{4})?|[a-zA-Z]{1,2}\d{1,2}\s?\d[a-zA-Z]{1,2}" placeholder="A valid UK postcode" />
<!-- to test in the browser console use: -->
/^(:?[a-zA-Z]{1,2}\d{1,2}\s?\d[a-zA-Z]{1,2})$/.test("tn12 6an")
@leeprobert
leeprobert / styles.css
Created Jul 21, 2015
Force webkit search input to look like a standard textfield
View styles.css
input[type="search"] { -webkit-appearance: textfield; }
You can’t perform that action at this time.