Skip to content

Instantly share code, notes, and snippets.

View hamsternik's full-sized avatar

Niki Khomitsevych hamsternik

View GitHub Profile
@ericdke
ericdke / resizeNSImage.swift
Last active March 3, 2023 13:47
Resize NSImage
func resize(image: NSImage, w: Int, h: Int) -> NSImage {
var destSize = NSMakeSize(CGFloat(w), CGFloat(h))
var newImage = NSImage(size: destSize)
newImage.lockFocus()
image.drawInRect(NSMakeRect(0, 0, destSize.width, destSize.height), fromRect: NSMakeRect(0, 0, image.size.width, image.size.height), operation: NSCompositingOperation.CompositeSourceOver, fraction: CGFloat(1))
newImage.unlockFocus()
newImage.size = destSize
return NSImage(data: newImage.TIFFRepresentation!)!
}
@kristopherjohnson
kristopherjohnson / methodNames.swift
Last active October 4, 2024 03:51
Get method names for an Objective-C class in Swift
import Foundation
/// Given pointer to first element of a C array, invoke a function for each element
func enumerateCArray<T>(array: UnsafePointer<T>, count: UInt32, f: (UInt32, T) -> ()) {
var ptr = array
for i in 0..<count {
f(i, ptr.memory)
ptr = ptr.successor()
}
}
@JeOam
JeOam / AutoLayout.md
Last active September 13, 2018 18:17
Auto Layout Tips

Auto Layout is a contraint-based, descriptive layout system. Describe the layout with constraints, and frames are calculated automatically.

Whay Auto Layout?

  • Relational: Codifying the relative way we describe interfaces
  • Dynamism: Improved responsiveness to changges
    • Metrics: iOS 6 to iOS 7, screen sizes, and rotation
      • The user can actually change the size of the font on the fly.
      • Using Auto Layout and using relationships to describe things like spacings, alignments, equal size, these are the things that are going to translate regardless of what the size of the container is, so the size of the control, the size of your contents. *Content: Localization
@hkhamm
hkhamm / installing_cassandra.md
Last active March 13, 2026 03:05
Installing Cassandra on Mac OS X

Installing Cassandra on Mac OS X

Install Homebrew

Homebrew is a great little package manager for OS X. If you haven't already, installing it is pretty easy:

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
@staltz
staltz / introrx.md
Last active July 19, 2026 16:25
The introduction to Reactive Programming you've been missing
@virasio
virasio / Singleton.h
Last active December 2, 2019 03:42
Singleton (Objective-C with ARC)
@interface MySingleton : NSObject
// ...
+ (instancetype) sharedInstance;
+ (instancetype) alloc __attribute__((unavailable("alloc not available, call sharedInstance instead")));
- (instancetype) init __attribute__((unavailable("init not available, call sharedInstance instead")));
+ (instancetype) new __attribute__((unavailable("new not available, call sharedInstance instead")));
@XVilka
XVilka / TrueColour.md
Last active July 13, 2026 20:43
True Colour (16 million colours) support in various terminal applications and terminals

THIS GIST WAS MOVED TO TERMSTANDARD/COLORS REPOSITORY.

PLEASE ASK YOUR QUESTIONS OR ADD ANY SUGGESTIONS AS A REPOSITORY ISSUES OR PULL REQUESTS INSTEAD!

@irazasyed
irazasyed / homebrew-permissions-issue.md
Last active July 8, 2026 13:32
Homebrew: Permissions Denied Issue Fix (OS X / macOS)

Homebrew Permissions Denied Issues Solution

sudo chown -R $(whoami) $(brew --prefix)/*

@hofmannsven
hofmannsven / README.md
Last active June 11, 2026 03:37
Git CLI Cheatsheet
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active June 17, 2026 19:56
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application: