Skip to content

Instantly share code, notes, and snippets.

View juliantejera's full-sized avatar

Julian Tejera-Frias juliantejera

View GitHub Profile
@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] {
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 / 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
@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");
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
NSLog(@"My token is: %@", deviceToken);
// Push Device Token to Server
}
@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
{