Skip to content

Instantly share code, notes, and snippets.

View juliantejera's full-sized avatar

Julian Tejera-Frias juliantejera

View GitHub Profile
@juliantejera
juliantejera / gist:705e8639f724aca3f56b
Created September 24, 2014 00:08
Observable Object Funglode
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace DemoMVVM.Models
{
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
NSLog(@"My token is: %@", deviceToken);
// Push Device Token to Server
}
@juliantejera
juliantejera / scrollViewDidScroll
Created February 25, 2015 02:08
Scroll View to top or bottom
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if(scrollView.contentOffset.y
>=
(scrollView.contentSize.height - scrollView.frame.size.height)){
NSLog(@"BOTTOM REACHED");
}
if(scrollView.contentOffset.y <= 0.0){
NSLog(@"TOP REACHED");
}
@juliantejera
juliantejera / ManagedDocumentCoordinator.swift
Created April 2, 2015 18:04
ManagedDocumentCoordinator
//
// ManagedDocumentHandler.swift
// DominicanFuel
//
// Created by Julian Tejera on 3/31/15.
// Copyright (c) 2015 Julian Tejera. All rights reserved.
//
import UIKit
let context = CoreDataManager.sharedInstance.managedObjectContext
let product = Product(context: context)
// modificas el producto como deseas
func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(animated)
CoreDataManager.sharedInstance.managedObjectContext.rollback()
}
@juliantejera
juliantejera / Prime.swift
Created August 10, 2016 22:03
Sieve of Erastosthene
func sieveOfErastosthene(max: Int) -> [Bool] {
// we assume every number is prime
var flags = Array(count: max + 1, repeatedValue: true)
flags[0] = false
flags[1] = false
let squareRoot = Int(sqrt(Double(max)))
for i in 2...squareRoot {
if flags[i] {
//
// RepositoryParserLiaison.swift
// Fire
//
// Created by Julian Tejera on 6/13/15.
// Copyright (c) 2015 Julian Tejera. All rights reserved.
//
import Foundation
@juliantejera
juliantejera / RainbowPlayground.swift
Last active July 1, 2017 01:41
How to draw a rainbow with Bezier Paths
//: Playground - noun: a place where people can play
import UIKit
import Foundation
import PlaygroundSupport
extension UIColor {
class var indigo: UIColor {
return UIColor(colorLiteralRed: 75.0/255.0, green: 0, blue: 130.0/255.0, alpha: 1)
@juliantejera
juliantejera / Models.swift
Created April 8, 2019 02:08
Human and Alien Models
struct Human: Decodable {
let age: Int
let name: String
}
struct Alien: Decodable {
let humans: [Human]
}
@juliantejera
juliantejera / Alien.json
Created April 8, 2019 02:28
How an Alien is Formed...
{
"humans": [
{
"age": 28,
"name": "Julian"
},
{
"age": 32,
"name": "Waldo"
},