Skip to content

Instantly share code, notes, and snippets.

View ArtSabintsev's full-sized avatar
😎
Having fun!

Arthur Ariel Sabintsev ArtSabintsev

😎
Having fun!
View GitHub Profile
- (void)clearCell
{
_textField.text = nil;
[_textField toggleFloatLabel:UIFloatLabelAnimationTypeHide];
}
@ArtSabintsev
ArtSabintsev / GiftCardFlowLayout.m
Created November 13, 2014 17:49
UICollectionFlowLayout - Cell Spacing in a UICollectionView Flow Layout.
//
// GiftCardFlowLayout.m
// ID.me Marketplace
//
// Created by Arthur Sabintsev on 9/7/14.
// Copyright (c) 2014 ID.me, Inc. All rights reserved.
//
#import "GiftCardFlowLayout.h"
@ArtSabintsev
ArtSabintsev / Example.md
Created January 30, 2015 02:55
NSString+Base64 (iOS 7+)

Encoding Strings

NSString *aString = @"Hello, iOS 7!" 
NSString *encodedString = [NSString encodeBase64String:aString]
NSLog(@"Encoded String %@", encodedString) // returns 'SGVsbG8sIGlPUyA3IQ=='

Decoding Strings

import java.text.DecimalFormat;
import java.util.Scanner;
public class PayAmmount {
public static void main(String[] args) {
double payRate
double hours;
Scanner keyScanner = new Scanner(System.in);
@ArtSabintsev
ArtSabintsev / gist:98a90e40195158127979
Created June 15, 2015 18:26
Open crontab in nano
env EDITOR=nano crontab -e
@ArtSabintsev
ArtSabintsev / CoreGraphicsGraident.m
Created May 30, 2012 14:01
Core Graphics Gradient (iOS 5 Compatible, ARC Compatible)
// Macros for the top and bottom colors of the gradient
#define kGradientTopColor {0.0f/255.0f, 0.0f/255.0f, 0.0f/255.0f, 1.0f}
#define kGradientBottomColor {209.0f/255.0f, 209.0f/255.0f, 209.0f/255.0f, 1.0f}
// Macro for the area that should be covered by the gradient
#define kGradientBounds self.bounds
// Customize your UIView (e.g., UIView, UILabel, UIButton, etc...) drawRect method
- (void)drawRect:(CGRect)rect
{
@ArtSabintsev
ArtSabintsev / SKTexture+Gradient.swift
Created October 14, 2015 18:06
SKTexture Gradient
extension SKTexture {
/* FIXME
This code breaks on iOS 8 (reference post)
http://stackoverflow.com/questions/19243111/spritekit-sktexture-crash/19248293#19248293
*/
convenience init(size: CGSize, firstColor: UIColor, lastColor: UIColor) {
guard let gradientFilter = CIFilter(name: "CILinearGradient") else {
self.init()
layout category tags
post
resource
html
css
javascript
resources
links

##specs

@implementation UIImage (WRExtensions)
#pragma mark -
#pragma mark Scale and crop image
- (UIImage*)imageByScalingAndCroppingForSize:(CGSize)targetSize
{
UIImage *sourceImage = self;
UIImage *newImage = nil;
CGSize imageSize = sourceImage.size;
@ArtSabintsev
ArtSabintsev / Native Base64 (Pre iOS7)
Created September 11, 2013 06:19
A category on NSString that exploits a set of CoreFoundation methods to create Base64 encoded strings. This is a simple solution that removes the need for external Base64 libraries in projects that targets apps that support iOS 2 - iOS 6. iOS 7 has a more concrete solution, but due to NDA, I cannot post it yet.
+ (NSString *)base64EncodeString:(NSString *)stringToEncode
{
CFHTTPMessageRef messageRef = CFHTTPMessageCreateEmpty(kCFAllocatorDefault, FALSE);
CFHTTPMessageAddAuthentication(messageRef, NULL, CFSTR("AS"), (__bridge CFStringRef)stringToEncode, kCFHTTPAuthenticationSchemeBasic, FALSE);
CFStringRef authStringRef = CFHTTPMessageCopyHeaderFieldValue(messageRef, CFSTR("Authorization"));
NSString *encodedString = [(__bridge NSString *)authStringRef substringFromIndex:10];
CFRelease(messageRef);