Skip to content

Instantly share code, notes, and snippets.

View hminaya's full-sized avatar
🎯
Focusing

Hector Minaya hminaya

🎯
Focusing
View GitHub Profile
@hminaya
hminaya / pal.cs
Last active December 17, 2015 10:09 — forked from jose-gomez/gist:5495370
namespace PalindromeGist
{
struct Program
{
public static bool Espalindromo(string word)
{
char[] origin = word.ToCharArray();
for (int i = 0; i < word.Length; i++)
{
if (origin[i] != origin[(origin.Length - 1) - i])
@hminaya
hminaya / palindrome-two.rb
Last active December 16, 2015 19:00
Segundo ejemplo en ruby
count = 0
File.open("seed.txt") do |f|
while line = f.gets
one, two = line.split(" ").map(&:to_i)
while (one <= two) do
one += 1
muestra = one.to_s
@hminaya
hminaya / capicua2.py
Last active December 16, 2015 18:59 — forked from imiric/capicua2.py
#!/usr/bin/env python
def is_palindrome(num):
return str(num) == str(num)[::-1]
def closest_higher(target, collection) :
"""Return the closest number to `target` in `collection`
that is higher than `target`"""
return max((target - i, i) for i in collection if (target - i) < 0)[1]
@hminaya
hminaya / palindrome-mono.cs
Created April 22, 2013 22:52
Ejemplo en C# (para correr con mono) de como sacar un palindromo
using System;
using System.IO;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
namespace palindrome
{
class MainClass
{
@hminaya
hminaya / palindrome-one.rb
Last active December 16, 2015 12:38
Primer ejemplo en ruby de como encontrar si un numero es un palíndromo
def is_palindrome?(num)
s = num.to_s
s == s.reverse
end
count = 0
File.open("seed.txt") do |f|
while line = f.gets
one = line.split[0]
two = line.split[1]
@hminaya
hminaya / seed.txt
Last active December 16, 2015 12:38
Data de prueba con numeros aleatorios
235952 696834
410744 1972018
482537 762623
266013 1506104
332936 1357451
115587 1881152
255431 833493
437349 1833622
384940 1333384
45184 1263934
@hminaya
hminaya / seed.rb
Created April 22, 2013 14:48
Genera un archivo con numeros aleatorios dentro de un rango
file = File.open("seed.txt", "w")
20.times do
one = Random.rand(1...500000)
two = Random.rand(500000...2000000)
file.write("#{one} #{two}\n")
end
@hminaya
hminaya / json-api-csharp.cs
Created April 15, 2013 01:07
get JSON api with C#
using System;
using System.Net;
using Newtonsoft.Json;
namespace api
{
class MainClass
{
public static void Main (string[] args)
{
@hminaya
hminaya / json-api-java.java
Last active May 11, 2018 10:45
get JSON api with Java
package com.hminaya.storage;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
@hminaya
hminaya / json-api-node.js
Last active December 16, 2015 05:19
get JSON api with node (server side javascript)
var http = require('http');
var url = 'http://www.emplea.do/jobs.json';
http.get(url, function(res) {
var body = '';
res.on('data', function(chunk) {
body += chunk;
});