Skip to content

Instantly share code, notes, and snippets.

@albertbori
albertbori / HideableUIView.swift
Last active August 9, 2018 10:14
iOS Swift Extension for easily hiding/showing UIViews constrained using Auto Layout
//
// HideableUIView.swift
// Albert Bori
//
// Created by Albert Bori on 5/19/15.
// Copyright (c) 2015 Albert Bori under the MIT license.
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//
@albertbori
albertbori / PlaceholderTextView.swift
Last active January 13, 2020 09:25
UITextView support for Placeholder text
import UIKit
import Foundation
@IBDesignable class PlaceholderTextView: UITextView, UITextViewDelegate
{
private let _placeholderColor: UIColor = UIColor(white: 0.78, alpha: 1)
private var _placeholderLabel: UILabel!
@IBInspectable var placeholder: String = "" {
didSet {
@albertbori
albertbori / MyDB.cs
Last active June 13, 2023 18:11
.NET EntityFramework Encryption Example (C#)
public class MyDB : IdentityDbContext<User>
{
//DBSet properties go here
public MyDB()
{
((IObjectContextAdapter)this).ObjectContext.ObjectMaterialized += new ObjectMaterializedEventHandler(ObjectMaterialized);
}
#region Encryption
@albertbori
albertbori / Installation.md
Last active May 4, 2024 18:21
Automatically disable Wifi when an Ethernet connection (cable) is plugged in on a Mac

Overview

This is a bash script that will automatically turn your wifi off if you connect your computer to an ethernet connection and turn wifi back on when you unplug your ethernet cable/adapter. If you decide to turn wifi on for whatever reason, it will remember that choice. This was improvised from this mac hint to work with Yosemite, and without hard-coding the adapter names. It's supposed to support growl, but I didn't check that part. I did, however, add OSX notification center support. Feel free to fork and fix any issues you encounter.

Most the credit for these changes go to Dave Holland.

Requirements

  • Mac OSX 10+
  • Administrator privileges
import Foundation
extension String
{
var length: Int {
get {
return countElements(self)
}
}