Skip to content

Instantly share code, notes, and snippets.

View fernandolopez's full-sized avatar

Fernando López fernandolopez

View GitHub Profile
#include <stdio.h> // por printf
#include <ctype.h> // por isalpha y tolower
#include <string.h> // por strlen y memcpy
int es_palindromo(const char *word) {
int i, j;
int ultimo = strlen(word) - 1;
// Descomentar para ver que viene en word en cada invocación
// printf("- {%s}\n", word);
for (i = 0, j = ultimo; i < j; i++, j--) {
#!/bin/bash
uso() {
echo "Uso: $0 [c|s] nickname" >&2
exit 1
}
if [ $# -ne 2 ]; then
uso
fi
@fernandolopez
fernandolopez / lmic_project_config.h
Created February 27, 2018 21:05
~/Arduino/libraries/arduino-lmic/project_config/lmic_project_config.h
// ~/Arduino/libraries/arduino-lmic/project_config/lmic_project_config.h
// project-specific definitions for otaa sensor
//#define CFG_eu868 1
//#define CFG_us915 1
#define CFG_au921 1
//#define CFG_as923 1
//#define CFG_in866 1
#define CFG_sx1276_radio 1
//#define LMIC_USE_INTERRUPTS
from xremotebot import *
import time
server = Server('ws://163.10.20.156:8000/api')
robot = Robot(server, server.reserve('n6', 6))
robot.forward(50, 1)
for i in range(20):
if robot.getObstacle(20):
robot.backward(50,1)
@fernandolopez
fernandolopez / ejemplo.py
Created November 10, 2017 12:46
ejemplo
from xremotebot import *
server = Server('ws://163.10.20.156:8000/api')
robot = Robot(server, server.reserve('n6', 6))
for i in range(20):
if robot.getObstacle(20):
robot.backward(50,1)
robot.turnLeft(50,.5)
robot.forward(80)
@fernandolopez
fernandolopez / ejemplo_estructuras_iterativas.py
Created May 8, 2016 18:54
Ejemplo de for y while grupo 16
def leer_codigo():
codigo = raw_input("Ingrese codigo (termina con xx): ")
if codigo == 'xx':
return None
else:
nombre = raw_input("Ingrese nombre del prod:")
precio = input("Ingrese el precio del prod: ")
return (nombre, codigo, precio)
def procesar():
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <assert.h>
char *digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char *base(int nro, int base, char *buff){
int length;
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char *invertir(char *str){
int last = strlen(str) - 1;
char swp;
for (int i = 0, j = last; i < j; i++, j--){
# -*- coding: utf-8 -*-
import sys
import subprocess
import functools
if sys.version_info.major == 2:
input = raw_input
@fernandolopez
fernandolopez / listcomprehensions.md
Created January 22, 2015 20:11
List comprehensions simuladas en Ruby

Trying to emulate list comprehensions syntax I came with this syntax that resembles haskell list comprehensions (by having several guards separated by , and allowing zero guards):

> (1..24).comp { |x| [x, x.even?, x > 6] }
=> [8, 10, 12, 14, 16, 18, 20, 22, 24]

> [nil, nil, 1, 2, 3, 4, 5].comp { |x| [x, x != 4] }
=> [nil, nil, 1, 2, 3, 5]

> [nil, nil, 1, 2, 3, 4, 5].comp { |x| [x] }

=> [nil, nil, 1, 2, 3, 4, 5]