Skip to content

Instantly share code, notes, and snippets.

@dchohfi
dchohfi / InoutScan.swift
Created November 5, 2019 19:56
Swift inout scan
extension Publisher {
public func inoutScan<Result>(
_ initialResult: Result,
_ nextPartialResult: @escaping (inout Result, Output) -> Void
) -> Publishers.InoutScan<Self, Result> {
return .init(upstream: self,
initialResult: initialResult,
nextPartialResult: nextPartialResult)
}

Keybase proof

I hereby claim:

  • I am dchohfi on github.
  • I am dchohfi (https://keybase.io/dchohfi) on keybase.
  • I have a public key ASBWalnthQyyVV-q4_YWfzgvlag0-1URL_Hd3wTb9CrzcQo

To claim this, I am signing this object:

@dchohfi
dchohfi / .swift
Created June 11, 2018 16:53
Apple custom typography
import UIKit
// swiftlint:disable file_length
extension UIColor {
static var link: UIColor {
return UIColor(r: 0, g: 152, b: 238)
}
static var toastNotification: UIColor {
return .white
@dchohfi
dchohfi / PageViewControllerSegmentedAdapter.swift
Created December 16, 2016 01:32
Connect UISegmentControll to UIPageViewController
import UIKit
final class PageViewControllerSegmentedAdapter: NSObject {
private let pageViewController: UIPageViewController
fileprivate let segmentControl: UISegmentedControl
fileprivate let viewControllers: [UIViewController]
fileprivate var selectedIndex: Int = 0
init(pageViewController: UIPageViewController, segmentControl: UISegmentedControl, viewControllers: [UIViewController]) {
@dchohfi
dchohfi / gist:85456ef9c2d5656d3023
Created April 27, 2015 17:19
O que dizer desse código que mal conheço mas já curto pakas?
- (void)changeDots {
switch (self.hasDots) {
case NO:
[_viDots removeAllActions];
[_viDots runAction:[NPPAction fadeOut]];
break;
case YES:
[_viDots removeAllActions];
[_viDots runAction:[NPPAction fadeIn]];
default:
@dchohfi
dchohfi / persistence.xml
Created September 17, 2012 20:16
persistence.xml
<persistence-unit name="">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class></class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
@dchohfi
dchohfi / Contato.h
Created June 20, 2012 15:05
NSCoding protocol
#import <Foundation/Foundation.h>
@interface Contato : NSObject <NSCoding>
@property (nonatomic, retain) NSString *nome;
@property (nonatomic, retain) NSString *email;
@property (nonatomic, retain) NSString *endereco;
@property (nonatomic, retain) NSString *telefone;
@property (nonatomic, retain) NSString *site;
@property (nonatomic, retain) UIImage *imagem;
@dchohfi
dchohfi / usuarios
Created May 25, 2012 22:15
Tarefas e usuarios
create table tarefas (id BIGINT NOT NULL AUTO_INCREMENT,descricao VARCHAR(255),finalizado BOOLEAN,dataFinalizacao DATE,primary key (id));
create table usuarios (login varchar(255), senha varchar(255));
@dchohfi
dchohfi / gist:2370777
Created April 12, 2012 20:31
JSON automatic parser
//
// JSONParser.m
// BusaoSP
//
// Created by Diego Chohfi on 4/12/12.
// Copyright (c) 2012 None. All rights reserved.
//
#import "JSONParser.h"
#import <objc/runtime.h>
@dchohfi
dchohfi / tableView:viewForHeaderInSection:
Created April 9, 2012 19:49
tableView:viewForHeaderInSection: like the default header view
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
float width = tableView.bounds.size.width;
int fontSize = 18;
int padding = 10;
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, width, fontSize)];
view.backgroundColor = [UIColor colorWithWhite:0 alpha:0];
view.userInteractionEnabled = YES;
view.tag = section;