Skip to content

Instantly share code, notes, and snippets.

View kdbdallas's full-sized avatar

kdbdallas kdbdallas

View GitHub Profile
@kdbdallas
kdbdallas / RaspberryPi_WelcomeMSG
Last active April 16, 2016 22:12
A "Graphical" Welcome Message With Lots of Handy Info. Put It In The Bottom Of Your .bashrc
function welcome_msg() {
local upSeconds="$(/usr/bin/cut -d. -f1 /proc/uptime)"
local secs=$((upSeconds%60))
local mins=$((upSeconds/60%60))
local hours=$((upSeconds/3600%24))
local days=$((upSeconds/86400))
local UPTIME=$(printf "%d days, %02dh%02dm%02ds" "$days" "$hours" "$mins" "$secs")
# calculate rough CPU and GPU temperatures:
local cpuTempC
@kdbdallas
kdbdallas / NSURLSessionBasicAuth
Created October 7, 2015 18:00
NSURLSession with Basic HTTP Auth
NSURLCredential *defaultCredential = [NSURLCredential credentialWithUser:LYKAPIUsername password:LYKAPIKey persistence:NSURLCredentialPersistencePermanent];
NSURL *APIURL = [NSURL URLWithString:LYKAPIURLRegister];
NSString *host = [APIURL host];
NSInteger port = [[APIURL port] integerValue];
NSString *protocol = [APIURL scheme];
NSURLProtectionSpace *protectionSpace = [[NSURLProtectionSpace alloc] initWithHost:host port:port protocol:protocol realm:nil authenticationMethod:NSURLAuthenticationMethodHTTPBasic];
NSURLCredentialStorage *credentials = [NSURLCredentialStorage sharedCredentialStorage];
@kdbdallas
kdbdallas / UIMainThreadGuard.m
Last active August 29, 2015 14:01 — forked from steipete/PSPDFUIKitMainThreadGuard.m
iOS: Find UI calls on background threads
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2013 Peter Steinberger. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
#import <objc/runtime.h>
#import <objc/message.h>
// Compile-time selector checks.
@kdbdallas
kdbdallas / AppKitMainThreadGuard.m
Last active August 29, 2015 14:01 — forked from andrewmichaelson/PSPDFUIKitMainThreadGuard.m
Mac: Find UI calls on background threads
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2013 Peter Steinberger. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
#import <objc/runtime.h>
#import <objc/message.h>
#import <Foundation/Foundation.h>
@kdbdallas
kdbdallas / RevealNoCode.md
Last active August 29, 2015 13:57 — forked from raven/Breakpoints_v2.xcbkptlist
Reveal available for all of your projects, without touching any source code

The laziest way to have Reveal available for all of your projects, without touching any source code

With the power of Xcode's symbolic User breakpoints, you can easily toggle on and off dynamically linking Reveal into your app.

The lazy way

Warning: This does not affect your current project or workspace breakpoints but will blast away any User breakpoints.

  1. Quit Xcode, and in terminal:
UI- and App Frameworks Evangelist - Jake Behrens, [email protected], twitter: @Behrens
- What's new in Cocoa
- Accessibility in iOS
- Building User Interfaces for iOS 7
- Getting Started with UIKit Dynamics
- What's new in Cocoa Touch
- What's New With Multitasking
- Best Practices for Cocoa Animation
- Improving Power Efficiency with App Nap
- Introducing Text Kit
//
// RVNReceiptValidation.m
//
// Created by Satoshi Numata on 12/06/30.
// Copyright (c) 2012 Sazameki and Satoshi Numata, Ph.D. All rights reserved.
//
// This sample shows how to write the Mac App Store receipt validation code.
// Replace kRVNBundleID and kRVNBundleVersion with your own ones.
//
// This sample is provided because the coding sample found in "Validating Mac App Store Receipts"
- (void)debugSubview
{
[self colorSubviewsForDebugParentView:self];
}
- (void)colorSubviewsForDebugParentView:(UIView*)view
{
CGFloat hue = ( arc4random() % 256 / 256.0 ); // 0.0 to 1.0
CGFloat saturation = ( arc4random() % 128 / 256.0 ) + 0.5; // 0.5 to 1.0, away from white
CGFloat brightness = ( arc4random() % 128 / 256.0 ) + 0.5; // 0.5 to 1.0, away from black
# MAC manipulators
alias random_mac='sudo ifconfig en0 ether `openssl rand -hex 6 | sed "s/\(..\)/\1:/g; s/.$//"`'
alias restore_mac='sudo ifconfig en0 ether YOUR_ORIGINAL_MAC_ADDRESS_GOES_HERE'
@kdbdallas
kdbdallas / Photoshop Colorize
Last active September 27, 2019 13:57
What Photoshop's Colorize option in the Hue/Saturation adjustment window does
The Colorize option changes the nature of the Hue/Saturation control.
When checked, it removes the color from an image and overlays the image with a tint of a single hue and saturation.
Each pixel's luminosity remains unchanged (actually, it is changed, but very little).
With the Colorize option, the Hue and Saturation values are no longer relative numbers based on an offset from a starting point.
Instead, they are absolute numbers.
The Hue value ranges from 0° to 360° and represents an absolute position on the color wheel (0° and 360° are the same color; red)
The Saturation value ranges from 0% to 100%.
If Saturation is changed to 0%, color will be negated and the pixels will go gray.
Using Hue/Saturation to colorize an image is not the same as making a duo tone.