Skip to content

Instantly share code, notes, and snippets.

a:~$ realm-object-server --configuration /etc/realm/configuration.yml
module.js:583
return process.dlopen(module, path._makeLong(filename));
^
Error: Module version mismatch. Expected 48, got 46.
at Error (native)
at Object.Module._extensions..node (module.js:583:18)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
@minikin
minikin / commands
Created September 29, 2016 07:33
realm testing
:~$ node -v
v4.4.2
:~$ npm -v
2.15.0
:~$ nano /var/log/realm-sync.log
empty file
:~$ curl http://localhost:9080
@minikin
minikin / .bash_profile
Created October 27, 2016 09:09 — forked from natelandau/.bash_profile
Mac OSX Bash Profile
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management
@minikin
minikin / getHDDSize.swift
Created January 31, 2017 08:44
Get size of hardrive on macOS
func getHDDSize() -> CGFloat {
do {
let fileAttributes = try FileManager.default.attributesOfFileSystem(forPath: "/")
if let size = fileAttributes[FileAttributeKey.systemSize] as? CGFloat {
return size
}
} catch { }
return 0
}
@minikin
minikin / loopThroughClass.m
Created February 8, 2017 08:51
Loop through all object properties at runtime: Objective-C
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
unsigned int numberOfProperties = 0;
objc_property_t *propertyArray = class_copyPropertyList([YourClass class], &numberOfProperties);
for (NSUInteger i = 0; i < numberOfProperties; i++) {
objc_property_t property = propertyArray[i];
NSString *name = [[NSString alloc] initWithUTF8String:property_getName(property)];
NSString *attributesString = [[NSString alloc] initWithUTF8String:property_getAttributes(property)];
@minikin
minikin / Iterate.swift
Last active January 24, 2020 22:52
Iterate over object class attributes in Swift
import UIKit
struct User {
var name = ""
var lastName = ""
var nickName = ""
var age = 0
}
var user = User()
@minikin
minikin / fonts.swift
Created February 12, 2017 22:44
Find fonts in your app
for family: String in UIFont.familyNames {
print("\(family)")
for names: String in UIFont.fontNames(forFamilyName: family) {
print("== \(names)")
}
}
@minikin
minikin / ImageExtensions.swift
Last active March 2, 2017 07:41
UIImage Extensions
extension UIImage {
func resizeImage(_ image: UIImage, newWidth: CGFloat) -> UIImage? {
let scale = newWidth / image.size.width
let newHeight = image.size.height * scale
UIGraphicsBeginImageContext(CGSize(width: newWidth, height: newHeight))
image.draw(in: CGRect(x: 0, y: 0, width: newWidth, height: newHeight))
let newImage = UIGraphicsGetImageFromCurrentImageContext()
guard let image = newImage else { return nil }
UIGraphicsEndImageContext()
// MARK: - Photos
func checkIfAuthorizedToAccessPhotos(_ handler: @escaping (_ isAuthorized: Bool) -> Void) {
switch PHPhotoLibrary.authorizationStatus() {
case .notDetermined:
PHPhotoLibrary.requestAuthorization{ status in
switch status {
case .authorized:
handler(true)
default:
@minikin
minikin / Run Script
Created April 4, 2017 07:31
Automatically Generating Warnings for TODOs in Xcode
TAGS="TODO:|FIXME:"
echo "searching ${SRCROOT} for ${TAGS}"
find "${SRCROOT}" \( -name "*.swift" \) -print0 \
| xargs -0 egrep --with-filename --line-number --only-matching "($TAGS).*\$" \
| perl -p -e "s/($TAGS)/ warning: \$1/"