Skip to content

Instantly share code, notes, and snippets.

View Rich2k's full-sized avatar
😀

Richard Hyland Rich2k

😀
View GitHub Profile
@dansinclair25
dansinclair25 / UIColor+wheel.swift
Created June 28, 2017 21:37
Generate a UIColor wheel from a CGFloat
extension UIColor {
static func wheel(_ pos: CGFloat) -> UIColor {
// We only care about what's left over from dividing pos by 255 (seeing as there are 255 values for each R, G, and B)
var pos = pos.truncatingRemainder(dividingBy: 255)
if pos < 85 {
return UIColor(red: 255 - pos * 3, green: 0, blue: pos * 3, alpha: 1.0)
}
@leonaka
leonaka / gist:51c1de59b64c863932f0
Created March 25, 2015 18:17
Tumblr- and Tweetbot-like view on top of UIActivityViewController, with appearance animation (put it on a subclass of UIActivityViewController)
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
CGFloat distance = 10.0;
[self.transitionCoordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {
[UIView performWithoutAnimation:^{
self.effectView.frame = CGRectMake(0, self.view.frame.size.height - self.effectView.frame.size.height - distance, self.view.frame.size.width, self.effectView.frame.size.height);
}];
self.effectView.frame = CGRectMake(0, -self.effectView.frame.size.height - distance), self.view.frame.size.width, self.effectView.frame.size.height);
@skyfishjy
skyfishjy / CursorRecyclerViewAdapter.java
Last active December 16, 2023 08:55
CursorRecyclerViewAdapter
/*
* Copyright (C) 2014 skyfish.jy@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@Shywim
Shywim / CursorRecyclerAdapter.java
Last active February 27, 2024 13:42
A custom Adapter for the new RecyclerView, behaving like the CursorAdapter class from previous ListView and alike. Now with Filters and updated doc.
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 Matthieu Harlé
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@cihancimen
cihancimen / string_contains_emoji
Created November 26, 2012 00:54
Check if an NSString contains an emoji character
- (BOOL)stringContainsEmoji:(NSString *)string {
__block BOOL returnValue = NO;
[string enumerateSubstringsInRange:NSMakeRange(0, [string length]) options:NSStringEnumerationByComposedCharacterSequences usingBlock:
^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop) {
const unichar hs = [substring characterAtIndex:0];
// surrogate pair
if (0xd800 <= hs && hs <= 0xdbff) {
if (substring.length > 1) {
const unichar ls = [substring characterAtIndex:1];