Skip to content

Instantly share code, notes, and snippets.

View armonge's full-sized avatar
🏠

Andrés Reyes Monge armonge

🏠
View GitHub Profile
@armonge
armonge / requirements.txt
Last active September 27, 2017 01:11
Gets the list of all urls in a website, outputs a CSV with url, title. Uses python3
beautifulsoup4==4.3.2
requests==2.3.0
@armonge
armonge / retry.py
Created August 13, 2014 14:30
Decorator for retrying a function if it fails
def retry(exception):
def retry_decorator(func):
def _wrapper(*args, **kwargs):
tries = 0
while True:
try:
return func(*args, **kwargs)
except exception as error:
tries += 1
if tries <= 5:
gitfs_remotes:
- https://github.com/saltstack-formulas/nginx-formula.git
- https://github.com/saltstack-formulas/apache-formula.git
- https://github.com/saltstack-formulas/mysql-formula.git
- https://github.com/saltstack-formulas/vim-formula.git
- https://github.com/saltstack-formulas/build-essential-formula.git
- https://github.com/saltstack-formulas/pip-formula.git
fileserver_backend:
- git
import itertools
import random
import math
def map_d(c):
return math.hypot(random.random(), random.random())
def reduce_d(count_inside, d):
if d < 1:
return count_inside + 1
@armonge
armonge / .vimrc
Created April 3, 2014 15:42
Compile less on save
function LessToCss()
let current_file = shellescape(expand('%:p'))
let filename = shellescape(expand('%:r'))
let command = "silent !lessc " . current_file . " " . filename . ".css"
echo 'less compilation finished'
execute command
endfunction
autocmd BufWritePost,FileWritePost *.less call LessToCss()
"""
String Calculator
1- The program can take 0, 1 or 2 numbers and will
return their sum, (for an empty string it will return 0)
for example "" or "1" or "1,2" -> 0, 1, 3
2- Allow the Add method to handle an unknown amount
of numbers
def fizzbuzz(number)
if number == 0
return '0'
elsif number % 15 == 0
return 'fizzbuzz'
elsif number % 3 == 0:
return 'fizz'
elsif number % 5 == 0:
return 'buzz'
end
function fizzbuzz(number){
if(number === 0){
return '0';
}
if(number % 3 === 0 && number % 5 === 0){
return 'fizzbuzz';
}
if(number % 3 === 0){
<?php
class FizzBuzz
{
static public function categorize($num) {
$result = '';
if($num === 0){
return '0';
}
def fizzbuzz(num):
if num == 0:
return '0'
if num % 3 == num % 5 == 0:
return 'fizzbuzz'
if num % 3 == 0:
return 'fizz'