Skip to content

Instantly share code, notes, and snippets.

View richrad's full-sized avatar

Richard Allen richrad

View GitHub Profile
@richrad
richrad / UIColor+HumanEyePleasing.swift
Created June 23, 2021 16:06 — forked from shakemno/UIColor+HumanEyePleasing.swift
UIColor + HumanEyePleasing - contrasting color extension (complementary or perceptive luminance)
extension UIColor {
// get a complementary color to this color
// https://gist.github.com/klein-artur/025a0fa4f167a648d9ea
var complementary: UIColor {
let ciColor = CIColor(color: self)
// get the current values and make the difference from white:
let compRed: CGFloat = 1.0 - ciColor.red
override func viewWillDisappear(animated: Bool) {
defer {
super.viewDidDisappear(animated)
}
guard let _ = self.navigationController?.viewControllers.indexOf(self) else {
print("going back")
return
}
}
@richrad
richrad / libjpeg.sh
Created December 18, 2015 02:56 — forked from dulacp/libjpeg.sh
Download & Compile Libjpeg for iOS (all architectures)
# Builds a Libjpeg framework for the iPhone and the iPhone Simulator.
# Creates a set of universal libraries that can be used on an iPhone and in the
# iPhone simulator. Then creates a pseudo-framework to make using libjpeg in Xcode
# less painful.
#
# To configure the script, define:
# IPHONE_SDKVERSION: iPhone SDK version (e.g. 8.1)
#
# Then go get the source tar.bz of the libjpeg you want to build, shove it in the
# same directory as this script, and run "./libjpeg.sh". Grab a cuppa. And voila.
import UIKit
extension CGSize {
init(width: Float, height: Float) {
self.width = CGFloat(width)
self.height = CGFloat(height)
}
}
@richrad
richrad / scrape_links.py
Created November 17, 2015 16:57
Print all the links on a webpage
from urllib.request import urlopen
from bs4 import BeautifulSoup
import re
import string
from collections import OrderedDict, Counter
def clean_input(input):
input = re.sub('\n+', ' ', input)
input = re.sub('\[[0-9]*\]', '', input)
input = re.sub(' +', ' ', input)
@richrad
richrad / preferences.txt
Created May 14, 2015 16:00
Arduino IDE preferences.txt
board=micro
browser.linux=mozilla
build.verbose=false
console=true
console.auto_clear=true
console.error.file=stderr.txt
console.length=500
console.lines=4
console.output.file=stdout.txt
editor.antialias=false
@richrad
richrad / keybase.md
Created September 18, 2014 15:46
keybase.md

Keybase proof

I hereby claim:

  • I am richrad on github.
  • I am richrad (https://keybase.io/richrad) on keybase.
  • I have a public key whose fingerprint is 7DF3 B0D0 01AC 1591 0652 5D60 B005 35A8 5C06 FA2C

To claim this, I am signing this object:

@richrad
richrad / floating_header.css
Created October 11, 2012 02:23
Floating Header CSS
#floating_header {
background-clip: border-box;
background-origin: padding-box;
background-color: #FFFFFF;
display: block;
height: auto;
position: fixed;
top: 0px;
width: 100%;
box-shadow: 0 3px 2px -2px #878787;