Skip to content

Instantly share code, notes, and snippets.

View javm's full-sized avatar

José A. Villarreal javm

View GitHub Profile
from pdfminer.pdfparser import PDFParser
from pdfminer.pdfdocument import PDFDocument
from pdfminer.pdfpage import PDFPage
from pdfminer.pdfpage import PDFTextExtractionNotAllowed
from pdfminer.pdfinterp import PDFResourceManager
from pdfminer.pdfinterp import PDFPageInterpreter
from pdfminer.pdfdevice import PDFDevice
from pdfminer.layout import LAParams
from pdfminer.converter import PDFPageAggregator
from urllib.request import urlopen
from bs4 import BeautifulSoup as bs
import re
import requests
rootPath = "http://www.cndc.org.ni/consultas/reportesDiarios/"
today = '03/02/2018'
def get_day_data(day):
content = requests.post(rootPath+"postDespacho/consultaResumen.php?fecha="+day)
table = bs(content.text, 'html.parser')
function permutations(s, cb){
let n = s.length;
function swap(i, j){
let tmp = s[i];
s[i] = s[j];
s[j] = tmp;
}
let c = [];
for(let i = 0; i < n; i++){
@javm
javm / heaps-permutations.js
Last active May 19, 2017 17:02
Heap's algorithm to generate the permutation of an array of n elemets
function permutations(s, cb){
let n = s.length;
function swap(i, j){
let tmp = s[i];
s[i] = s[j];
s[j] = tmp;
}
function heapGenerate(n){
@javm
javm / permutation.js
Created April 4, 2017 04:20
Generates the permutations of the elements in an array
function permutation(a){
let res = [];
for(let i=0; i<a.length; i++){
let restA = a.slice(0,i).concat(a.slice(i+1));
let rest = permutation( restA);
if(rest.length === 0){
res.push([a[i]]);
}else{
for(let j=0; j<rest.length; j++){
@javm
javm / test2.js
Created March 23, 2017 22:12
Looks for the minimal interval to sort
function solution(A){
console.log(A);
var swaps = [];
function checkRight(index){
let right = true, i=index + 1;
while(right && i < A.length){
@javm
javm / generator.js
Last active January 5, 2017 21:00
My first generator ES6
var co = require('co');
var contentful = require('contentful-management');
var cc = contentful.createClient({
accessToken: process.env.CONTENTFUL_MANAGEMENT_TOKEN
});
var getEntriesGenerator = function* (space, type){
let allItems = [];
let skip = 0;
let total = 1;
while(skip < total){
@javm
javm / flat.rb
Last active September 26, 2016 05:22
Function to flat an array of integers
# Flat array
#input = [[1,2,[3]],4, 5, [6,7]]
# How to use it:
# 1. ruby flat.rb
# 2. Type the input e.g: [[1,2,[3]],4, 5, [6,7]]
# 3. Type Enter and Ctrl-D
# it will print the oputput
def flat_array (input_a)
flatten = [];
@javm
javm / bluebird_promises.js
Last active August 29, 2015 14:14
Catching errors with bluebird promises
addPreference: function(preference){
var that = this;
return Question.findOne(preference.questionId)
.populate('configurator')
.then(function(question){
return Preference.create({
configurator: question.configurator.id,
question: question.id,
selectedAnswer: preference.selectedAnswer,
household: that.id
@javm
javm / selection-sort.rb
Last active August 29, 2015 13:57
Selection sort implementation in ruby
#!/usr/bin/env ruby
INPUT_SIZE = 50
MAX_VAL = 100
input = Array.new(INPUT_SIZE)
$num_comparisons = 0;
#Intializing the input
for i in 0..INPUT_SIZE - 1