Skip to content

Instantly share code, notes, and snippets.

View jimmyhoran's full-sized avatar
🛠️
Working on my own thing

Jimmy Horan jimmyhoran

🛠️
Working on my own thing
View GitHub Profile
@jimmyhoran
jimmyhoran / uuid.sh
Created April 17, 2023 23:38 — forked from dhoelle/uuid.sh
bash function to generate a random, lower-cased UUID in MacOS
uuid () {
local newuuid=${$(uuidgen):l}
echo -n ${newuuid} | pbcopy
echo "copied ${newuuid} to clipboard"
}
@jimmyhoran
jimmyhoran / README.md
Created September 28, 2021 07:17 — forked from magnetikonline/README.md
List all Git repository objects by size.

List all Git repository objects by size

Summary

Bash script to:

  • Iterate all commits made within a Git repository.
  • List every object at each commit.
@jimmyhoran
jimmyhoran / .gitattributes
Created March 29, 2020 06:51 — forked from asmallteapot/.gitattributes
Diff Xcode localizable strings files in Git.
*.strings utf16 diff=localizablestrings
@jimmyhoran
jimmyhoran / web-servers.md
Created December 11, 2019 10:43 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@jimmyhoran
jimmyhoran / UINavigationBar+Height.swift
Created February 18, 2018 07:36 — forked from siberianisaev/UINavigationBar+Height.swift
Change height of UINavigationBar
import Foundation
private var AssociatedObjectHandle: UInt8 = 0
extension UINavigationBar {
var height: CGFloat {
get {
if let h = objc_getAssociatedObject(self, &AssociatedObjectHandle) as? CGFloat {
@jimmyhoran
jimmyhoran / auth.markdown
Created December 31, 2017 06:26 — forked from mlynch/auth.markdown
AngularJS Authentication and CORS

Single Page Apps are ruling the world and AngularJS is leading the charge. But many of the lessons we learned in the Web 2.0 era no longer apply, and few are as drastically different as authentication.

CORS

CORS is an oft-misunderstood feature of new browsers that is configured by a remote server. CORS stands for Cross-Origin-Resource-Sharing, and was designed to make it possible to access services outside of the current origin (or domain) of the current page.

Like many browser features, CORS works because we all agree that it works. So all major browsers like Chrome, Firefox, and IE support and enforce it. By using these browsers, you benefit from the security of CORS.

That means certain browsers do not enforce it, so it is not relevant there. One large example is a native Web View for things like Cordova and Phonegap. However, these tools often have configuration options for whitelisting domains so you can add some security that way.

@jimmyhoran
jimmyhoran / authInterceptor.js
Created December 31, 2017 06:26 — forked from bettysteger/authInterceptor.js
Set specific http headers on every http request from cookies (angular)
'use strict';
/**
* Authentication with token and email for every server request. (Sets HTTP headers)
*
* This interceptor shows the error from the server (i18n key).
* Also sets global error variable if the request fails and redirects the user to '/' when he is not authorized.
* @see http://engineering.talis.com/articles/client-side-error-logging/
*/
app.factory('authInterceptor', function ($rootScope, $q, $cookies, $location, $timeout) {
@jimmyhoran
jimmyhoran / subl
Created November 14, 2017 09:49 — forked from yoeun/subl
subl command on linux
#!/bin/sh
# save to /usr/local/bin/subl
nohup /path/to/Sublime\ Text\ 2/sublime_text $1 >/dev/null 2>&1 &
func setTitle(title:String, subtitle:String) -> UIView {
let titleLabel = UILabel(frame: CGRect(x:0, y:-5, width:0, height:0))
titleLabel.backgroundColor = UIColor.clear
titleLabel.textColor = UIColor.gray
titleLabel.font = UIFont.boldSystemFont(ofSize: 17)
titleLabel.text = title
titleLabel.sizeToFit()