Skip to content

Instantly share code, notes, and snippets.

Avatar
🐍

Lucien Doellinger Lucien

🐍
View GitHub Profile
@Lucien
Lucien / String+NSRange.swift
Created Oct 11, 2019
Substring from NSRange
View String+NSRange.swift
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])
}
}
View keybase.md

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:

View UIImage+Extensions.swift
import Foundation
extension UIImage {
func crop(rect: CGRect) -> UIImage? {
var scaledRect = rect
scaledRect.origin.x *= scale
scaledRect.origin.y *= scale
scaledRect.size.width *= scale
View CGImage+extensions.swift
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)
View keybase.md

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 Aug 25, 2021
Moving navBar with scrollViewDidScroll:
View gist:7217914
typedef NS_ENUM(NSInteger, ScrollDirection)
{
ScrollDirectionDown = -1,
ScrollDirectionNone,
ScrollDirectionUp
};
###################################
[RPMDefines statusBarSize].height = 20;
@Lucien
Lucien / track-to-text.applescript
Last active Jan 27, 2017 — forked from poritsky/track-to-text.applescript
Get current stream title if available, otherwise show song's current artist - name
View track-to-text.applescript
# 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 Dec 11, 2015
Filter NSArray with strings matching: a*or
View gist:4673458
NSArray *aporWords = @[@"apor", @"amor", @"calor", @"aviador"];
NSArray *filteredArray = [aporWords filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"SELF MATCHES %@", @"\\b[a][a-z][o][r]\\b]"]];
View gist:3057924
- (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)];