Skip to content

Instantly share code, notes, and snippets.

View aral's full-sized avatar

Aral Balkan aral

View GitHub Profile
@aral
aral / 00_readme.md
Last active April 28, 2022 14:29
My fish shell configuration files

Instructions

Install plugins using Fisher.

Tide prompt customisation

Replace .config/fish/functions/_tide_item_git.fish with the file here to use words instead of symbols to describe git repository state.

@aral
aral / .zshrc
Created January 17, 2021 10:59
# Load Antigen
# (zsh plugin manager that can install plugins from git repositories)
source "/home/aral/antigen.zsh"
# Load oh-my-zsh.
antigen use oh-my-zsh
# Plugins from default repository
# (robbyrusell’s oh-my-zsh)
antigen bundle git

Why

  • You have a laptop with a 13" screen and 1920x1080 resolution and a 4K external monitor.
  • You run the laptop at 1x scale.
  • You run the 4K screen at 2x scale (pixel doubled).
  • You’re running elementary OS 5.x (Hera) or elementary OS 6 (Odin)

Which means that text scale should be 1x when the 4K monitor is plugged in but it should be larger than that (at least ~1.5x) to be legible on the laptop’s screen. (Yes, the manufacturer of the laptop chose the wrong resolution for the screen. It should have been QHD (2560 × 1440) or at most QHD+ (3200×1800) so that you could run it confortably pixel doubled.)

Anyway, it’s not and you’ve already bought it (and it’s otherwise an excellent laptop) but you don’t want to change the text scale every time you plug it into and unplug it from your external monitor.

@aral
aral / whatdb-proposed-syntax.md
Last active May 31, 2023 13:16
WhatDB? Proposed syntax.

WhatDB?

Proposed syntax.

Preparing a query

Internally, this prepares the predicate for an array.filter() operation.

.where( propertyName ) : Start query. Returns query object.
@aral
aral / NSView+ChangeAnchorPointWithoutMakingTheLayerJump.swift
Created July 18, 2015 21:01
A replacement for the anchorPoint property that doesn’t make the layer jump
//
// NSView+ChangeAnchorPointWithoutMakingTheLayerJump.swift
//
// Setting .anchorPoint on a layer makes the layer jump which is most
// likely not what you want. This extension fixes that. Useful for Core Animation.
//
// Usage: (e.g., to set the anchor point to the centre)
//
// myView.setAnchorPoint(CGPointMake(0.5, 0.5))
//
@aral
aral / NSView+CustomTaggable.swift
Last active May 27, 2016 19:53
Tag support in Interface Builder for custom NSViews
//
// NSView+CustomTaggable.swift
//
// Allows you to set tags in Interface Builder for custom NSViews.
//
// Usage:
//
// Your custom view must implement the CustomTaggable protocol. Then, in your custom
// NSView, declare the customTag property like this:
//
@aral
aral / gist:300a0588563d4f52a950
Last active August 29, 2015 14:25
Example of allowing free text entry of significant tokens in Interface Builder (for an @IBDesignable view) using a bitmask.
// Unfortunately, this has to be a string right now as IBInspectable enums are not supported at the moment.
@IBInspectable var alignmentToParentName:String = "top right"
{
didSet
{
var name = (alignmentToParentName.lowercaseString as NSString)
let top = 0b00, bottom = 0b10, right = 0b00, left = 0b01
var bitmask = 0b0
// The default, even if garbage is entered in Interface Builder, is top right.
@aral
aral / keybase.md
Created June 20, 2015 12:50
Keybase proof

Keybase proof

I hereby claim:

  • I am aral on github.
  • I am aral (https://keybase.io/aral) on keybase.
  • I have a public key whose fingerprint is FB1B E897 B399 F107 780A B004 B89F B743 1702 6216

To claim this, I am signing this object:

@aral
aral / gist:84ddf7ac37be079632ab
Last active July 31, 2018 20:26
NSPopover .appearance property is NSAppearance in Swift, not NSPopoverAppearance as per the docs
// The docs say that the appearance property of an NSPopover should be set to an
// NSPopoverAppearance enum but it actually expects an NSAppearance instance.
// e.g., in an NSViewController subclass:
let popover = NSPopover()
popover.contentViewController = self.storyboard?.instantiateControllerWithIdentifier("someViewController") as? NSViewController
popover.appearance = NSAppearance(named: NSAppearanceNameVibrantLight)
popover.behavior = NSPopoverBehavior.Transient
@aral
aral / gist:f65d30da4aff818af3c4
Last active August 29, 2015 14:17
AnyObject? to unwrapped value
let a = NSDictionary(object: NSNumber(bool: true), forKey: "boolKey")
let b: AnyObject? = a.objectForKey("boolKey")
if let b:AnyObject = b, c:NSNumber = (b as? NSNumber) where c.boolValue == true
{
println("It’s true.")
}