Skip to content

Instantly share code, notes, and snippets.

View Lucien's full-sized avatar
🐍

Lucien Doellinger Lucien

🐍
View GitHub Profile
@Lucien
Lucien / String+NSRange.swift
Created October 11, 2019 21:27
Substring from NSRange
extension String {
func substring(range: NSRange) -> String {
let location = range.lowerBound
let lenght = range.upperBound
let start = index(startIndex, offsetBy: location)
let end = index(start, offsetBy: length - location)
return String(self[start ..< end])
}
}
@Lucien
Lucien / keybase.md
Last active September 1, 2019 04:12

Keybase proof

I hereby claim:

  • I am lucien on github.
  • I am lucienc (https://keybase.io/lucienc) on keybase.
  • I have a public key ASBsIqqzG0YSb4suvNHgqKxBnbuWDRiRCAEwZ6i9asWLiQo

To claim this, I am signing this object:

import Foundation
extension UIImage {
func crop(rect: CGRect) -> UIImage? {
var scaledRect = rect
scaledRect.origin.x *= scale
scaledRect.origin.y *= scale
scaledRect.size.width *= scale
@Lucien
Lucien / CGImage+extensions.swift
Created April 10, 2017 14:23
CGImage operations
import UIKit
extension CGImage {
func increaseWidthToMultipleOfSeventeen(completion: @escaping (CGImage?) -> (Void)) {
DispatchQueue.global(qos: .background).async { [weak self] in
guard let strongSelf = self else {
DispatchQueue.main.async {
completion(nil)

Keybase proof

I hereby claim:

  • I am Lucien on github.
  • I am lucienc (https://keybase.io/lucienc) on keybase.
  • I have a public key whose fingerprint is 4445 E787 5A72 DCBA B913 8F61 94EE BBAE A680 F365

To claim this, I am signing this object:

@Lucien
Lucien / gist:7217914
Last active August 25, 2021 18:08
Moving navBar with scrollViewDidScroll:
typedef NS_ENUM(NSInteger, ScrollDirection)
{
ScrollDirectionDown = -1,
ScrollDirectionNone,
ScrollDirectionUp
};
###################################
[RPMDefines statusBarSize].height = 20;
@Lucien
Lucien / track-to-text.applescript
Last active January 27, 2017 22:58 — forked from poritsky/track-to-text.applescript
Get current stream title if available, otherwise show song's current artist - name
# Get current song, album and artist from iTunes.
#
# Intended for use with Smile Software's TextExpander:
# http://www.smilesoftware.com/TextExpander/index.html
#
# Set up as a snippet to turn current track into text. A nice way to spin your wheels while writing/coding/contemplating the shape of the universe.
tell application "iTunes"
set current_song to the name of current track
set current_artist to the artist of current track
@Lucien
Lucien / gist:4673458
Last active December 11, 2015 22:58
Filter NSArray with strings matching: a*or
NSArray *aporWords = @[@"apor", @"amor", @"calor", @"aviador"];
NSArray *filteredArray = [aporWords filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"SELF MATCHES %@", @"\\b[a][a-z][o][r]\\b]"]];
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.viewController = [[JBViewController alloc] initWithNibName:@"JBViewController" bundle:nil];
self.window.rootViewController = self.viewController;
// ADD THIS LINE:
[self.window setTransform:CGAffineTransformMakeScale(0.81, 0.81)];