Skip to content

Instantly share code, notes, and snippets.

View pedrogk's full-sized avatar

Pedro Galvan pedrogk

View GitHub Profile
@pedrogk
pedrogk / ptolemy.java
Last active August 29, 2015 14:10
Listado 1. Aplicación de aspectos y DbC con Ptolemy
// El evento se notifica cuando Entero cambia
void event IntEvento {
// variables de contexto
int x,y;
// Contrato translúcido. Iniciamos con precondición.
requires x < 25 && y < 120
assumes {
next.invoke();
establishes next.x() == old(next.x());
}
@pedrogk
pedrogk / gist:686b3edfa8d41f09177f
Created May 11, 2015 02:12
SG47. Arbol binario en Pascal 1
nodoptr = ^nodo; //el apuntador del nodo apunta a un nodo
nodo = record //esta es la definición del nodo
algúndato: string; //palabra a guardar
izquierda, derecha: nodoptr;
end;
@pedrogk
pedrogk / App.cs
Last active August 29, 2015 14:21
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xamarin.Forms;
namespace SG {
public class App {
public static Page GetMainPage() {
return new ContentPage {
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"
}