Skip to content

Instantly share code, notes, and snippets.

View ajself's full-sized avatar
🏠
Working from home

AJ Self ajself

🏠
Working from home
  • Ford Motor Company
  • Minneapolis, MN
View GitHub Profile
[
{
"id": "IMPRESSION_POST",
"url": "https://tps.doubleverify.com/visit.jpg?ctx=10562434&cmp=23852888&sid=6088994&plc=272648324&adsrv=1&btreg=&btadsrv=&crt=&tagtype=&dvtagver=6.1.img&",
"label": ""
},
{
"id": "IMPRESSION_POST",
"url": "https://ad.doubleclick.net/ddm/trackimp/N8031.163254IMGUR.COM/B23852888.272648324;dc_trk_aid=467310045;dc_trk_cid=131882115;ord=1589214351857;dc_lat=;dc_rdid=;tag_for_child_directed_treatment=;tfua=?",
"label": ""
@ajself
ajself / rotatable.swift
Last active January 31, 2021 06:09
Rotate UIViewControllers that conform to a protocol
/*
This is an update to an example found on http://www.jairobjunior.com/blog/2016/03/05/how-to-rotate-only-one-view-controller-to-landscape-in-ios-slash-swift/
The code there works, with some updating to the latest Swift, but the pattern isn't very Swifty. The following is what I found to be more helpful.
*/
/*
First, create a protocol that UIViewController's can conform to.
This is in opposition to using `Selector()` and checking for the presence of an empty function.
*/
@ajself
ajself / update_build_number.sh
Created April 6, 2017 11:38
Update build numbers
# Update build number with number of git commits
# adapted from http://blog.curtisherbert.com/automated-build-numbers/
buildNumber=$(git rev-list HEAD --count)
echo "Updating build number to $buildNumber"
dsym_plist="${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Info.plist"
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
if [ -f "$DSYM_INFO_PLIST" ] ; then
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$dsymPlist"
fi
@ajself
ajself / collectionViewCellLocation.swift
Created April 5, 2017 14:17
Get location of cell for UICollectionView previewing - peek/pop
// I was getting bad results for collectionView.indexPathForItem(at: location)
// Ends up the scroll view content offset needs to be taken into consideration.
func previewingContext(_ previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? {
guard let collectionView = collectionView else { return nil }
// The magic sauce
let cellLocation = CGPoint(x: location.x + collectionView.contentOffset.x,
y: location.y + collectionView.contentOffset.y)
@ajself
ajself / ps-to-svg.js
Created December 1, 2014 20:23
PS to SVG
/*
<javascriptresource>
<name>Save as SVG</name>
<about>Name a layer or layerset with .svg to convert it.</about>
</javascriptresource>
*/
var SvgWiz = SvgWiz || {
settings : {
scriptName : 'svgexport',

Keybase proof

I hereby claim:

  • I am ajself on github.
  • I am ajself (https://keybase.io/ajself) on keybase.
  • I have a public key whose fingerprint is 9B46 EB7A D0FA 76D6 BE4F 4C85 82CA 684D 53E7 5E1F

To claim this, I am signing this object:

@ajself
ajself / pySecureServer.py
Created August 15, 2013 21:30
Secure python SimpleHTTPServer
# http://www.piware.de/2011/01/creating-an-https-server-in-python/
# openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
import BaseHTTPServer, SimpleHTTPServer
import ssl
httpd = BaseHTTPServer.HTTPServer(('localhost', 4443), SimpleHTTPServer.SimpleHTTPRequestHandler)
httpd.socket = ssl.wrap_socket (httpd.socket, certfile='path/to/localhost.pem', server_side=True)
httpd.serve_forever()
randomHSLAColor = ->
getRandomInRange = (min, max) ->
return Math.floor(Math.random() * (max - min + 1)) + min
"hsla(#{getRandomInRange(0, 360)}, #{getRandomInRange(70, 100)}%, #{getRandomInRange(45, 55)}%, 0.6)"
@ajself
ajself / custom_key_bindings.json
Last active December 16, 2015 07:38
My custom keybindings for Sublime Text 2
[
{ "keys": ["super+shift+d"], "command": "toggle_side_bar" },
{ "keys": ["super+r"], "command": "refresh_folder_list"},
{ "keys": ["ctrl+shift+t"], "command": "delete_trailing_spaces" },
// Origami
{ "keys": ["super+k", "k"], "command": "travel_to_pane", "args": {"direction": "up"} },
{ "keys": ["super+k", "l"], "command": "travel_to_pane", "args": {"direction": "right"} },
{ "keys": ["super+k", "j"], "command": "travel_to_pane", "args": {"direction": "down"} },
{ "keys": ["super+k", "h"], "command": "travel_to_pane", "args": {"direction": "left"} },