Skip to content

Instantly share code, notes, and snippets.

View humbhenri's full-sized avatar

Humberto Pinheiro humbhenri

View GitHub Profile
@humbhenri
humbhenri / get-images.py
Created January 1, 2014 18:43
Download images in parallel using python
from BeautifulSoup import BeautifulSoup
from functools import partial
from urllib import urlretrieve
from urlparse import urljoin, urlparse
import argparse
import multiprocessing
import os
import sys
import urllib2
@humbhenri
humbhenri / get-images.clj
Last active January 1, 2016 22:49
Download images from a page in parallel
(ns get-images.core
(:require [clojure.tools.cli :refer [parse-opts]]
[net.cgrand.enlive-html :refer [select html-resource]]
[clojure.string :refer [split join]]
[clojure.java.io :refer [input-stream output-stream copy]])
(:import [java.net URL]
[java.io File])
(:gen-class))
(def options
@humbhenri
humbhenri / reddit.go
Created January 5, 2014 20:29
List reddit entries in golang
package main
import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"net/http"
)
@humbhenri
humbhenri / Champernowne.go
Created January 14, 2014 17:22
Champernowne constant
package main
import (
"fmt"
"math"
)
func main() {
var champernowne float64
for n := 1; n <= 10; n++ {
@humbhenri
humbhenri / euler40.go
Last active January 3, 2016 06:29
Project Euler Problem 40
package main
import (
"bytes"
"fmt"
"strconv"
)
func main() {
var champernowne bytes.Buffer
@humbhenri
humbhenri / avl.go
Created January 23, 2014 00:24
AVL Tree in golang
package main
import (
"fmt"
//"bytes"
//"strconv"
)
type AVLTree struct {
Val int
@humbhenri
humbhenri / markov.py
Created February 8, 2014 16:01
Markov Chain implementation in python
# Markov Chain Algorithm (The Practice of Programming pg 62)
# set w1 and w2 to be the first two words in the text
# print w1 and w2
# loop:
# randomly choose w3, one of successors of prefix w1 and w2
# print w3
# replace w1 and w2 by w2 and w3
# repeat loop
import random
IDENTIFICATION DIVISION.
PROGRAM-ID. EULERPROB1.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 COUNTER PIC 9999 VALUE 1.
01 TOTAL PIC 9(6) VALUE 0.
01 REST PIC 999.
88 DIVISIBLE VALUE ZERO.
for {set i 3} {$i < 1000} {inc i} {if {$i % 3 == 0 || $i % 5 == 0} {set total [expr {$total + $i}]}}
#!/usr/bin/tclsh
# Read a configuration file
# http://rosettacode.org/wiki/Read_a_configuration_file
# Qui Mar 6 20:37:26 BRT 2014
# parameters to load
set fullname ""
set favouritefruit ""
set needspeeling no
set seedsremoved no