Skip to content

Instantly share code, notes, and snippets.

View pedrogk's full-sized avatar

Pedro Galvan pedrogk

View GitHub Profile
using System;
using Android.App;
using Android.Content.PM;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Xamarin.Forms.Platform.Android;
namespace SG.Droid {
using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using Xamarin.Forms;
namespace SG.iOS {
[Register("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate {
var loginPage = new ContentPage {
Title = "Profile",
Icon = "Profile.png",
Content = new StackLayout {
Spacing = 20, Padding = 50, VerticalOptions = LayoutOptions.Center,
Children = {
new Entry { Placeholder = "Username" },
new Entry { Placeholder = "Password", IsPassword = true },
new Button {
Text = "Login",
var osName = string.Empty;
if (Device.OS == TargetPlatform.iOS)
osName = "Hola iOS!";
if (Device.OS == TargetPlatform.Android)
osName = "Hola Droid!";
if (Device.OS == TargetPlatform.WinPhone)
osName = "Hola WinPhone!";
@pedrogk
pedrogk / employee.swift
Last active September 25, 2015 23:07
Employee
class Employee: Equatable, Hashable {
var ID: Int
var personalInformation: PersonalInformation
var wage: Double
init(ID: Int, personalInformation: PersonalInformation, wage: Double) {
self.ID = ID
self.personalInformation = personalInformation
self.wage = wage
}
@pedrogk
pedrogk / personalinformation.swift
Created September 25, 2015 23:10
PersonalInformation
struct PersonalInformation {
var name: String
var address: String
var dateOfBirth: NSDate
var age: Int {
get {
var today = NSDate()
var aTimeInterval =
today.timeIntervalSinceDate(dateOfBirth)
@pedrogk
pedrogk / gender.swift
Created September 26, 2015 00:56
Gender
import UIKit
enum Gender: Printable {
case Female
case Male
var description: String {
switch self {
case .Male: return "Male"
case .Female: return "Female"
}
@pedrogk
pedrogk / funciones.swift
Created September 26, 2015 00:58
Funciones
func getBound(anArray: [Int], test: (Int, Int) -> Bool) -> Int {
var bound = anArray[0]
for item in anArray[1..<anArray.count] {
if test(item, bound) {
bound = item
}
}
return bound
}
@pedrogk
pedrogk / airline.swift
Created September 26, 2015 01:03
Airline
class Airline {
static var corporateInformation = CorporateInformation(
name: "Bad Airlines",
address: "Bad Street 666",
webSiteURL: "www.bad.com",
)
var employees: Set<Employee>
var numberOfEmployees: Int {
get {
@pedrogk
pedrogk / cuadrado.prolog
Created November 17, 2015 05:00
Prolog code for finding magic squares 3x3
/* condiciones iniciales */
numero(1).
numero(2).
numero(3).
numero(4).
numero(5).
numero(6).
numero(7).
numero(8).
numero(9).