Skip to content

Instantly share code, notes, and snippets.

View pedrogk's full-sized avatar

Pedro Galvan pedrogk

View GitHub Profile
var o = {
a: 2,
m: function(b){
return this.a + 1;
}
};
console.log(o.m()); // 3
// 'this' se refiere a 'o' cuya propiedad 'a' vale 2,
// así que m() regresa 3.
var o = {
a: 2,
m: function(b){
return this.a + 1;
}
};
// Asumamos que tenemos un objeto o, con propiedades a y b:
// {a: 1, b: 2}
// o.[[Prototype]] tiene las propiedades b y c:
// {b: 3, c: 4}
// Finalmente, o.[[Prototype]].[[Prototype]] es null.
// Así que la cadena de prototipos queda como
// {a:1, b:2} ---> {b:3, c:4} ---> null
console.log(o.a); // 1
// Existe una propiedad 'a' en o? Sí, y su valor es 1.
import paho.mqtt.publish as publish
import time
print(“Enviando 0...")
publish.single("ledStatus", "0", hostname=“tuserver”)
time.sleep(3)
print(“Enviando 1...")
publish.single("ledStatus", "1", hostname=“tuserver”)
#include <EEPROM.h>
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include <Wire.h>
#include <Adafruit_INA219.h>
const char* ssid = "Tu Wifi";
const char* password = "tupassword";
const char* mqtt_server = "tuservidor";
@pedrogk
pedrogk / dinamica_teclado.pas
Last active March 1, 2016 03:38
Rutinas para generar perfil biometrico en base a dinámica de teclado usando THPCounter
begin
HPCounter1.Start;
end;
procedure TForm1.Edit1KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
//alto al conteo al soltar la tecla presionada
var
valor : string;
valor1 : integer;
@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).
@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 / 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 / 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"
}